当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


C# Char.ToLowerInvariant(Char)用法及代码示例


此方法用于使用不变区域性的大小写规则将Unicode字符的值转换为其小写形式。

用法:

public static char ToLowerInvariant (char c);

在这里,c是要转换的Unicode字符。


返回值:如果c已经小写或不是字母,则此方法返回c参数的小写等效项或c的不变值。

以下示例程序旨在说明Char.ToLowerInvariant(Char)方法的用法:

示例1:

// C# program to demonstrate 
// Char.ToLowerInvariant() 
// Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
        // calling get() Method 
        get('A'); 
        get('a'); 
        get('B'); 
        get('b'); 
    } 
  
    // Defining get() method 
    public static void get(char c) 
    { 
  
        // getting Unicode character 
        // using ToLowerInvariant() Method 
        char val = Char.ToLowerInvariant(c); 
  
        // display the char value 
        Console.WriteLine("The lowercase equivalent"+ 
                       " of the {0} is {1}", c, val); 
    } 
}
输出:
The lowercase equivalent of the A is a
The lowercase equivalent of the a is a
The lowercase equivalent of the B is b
The lowercase equivalent of the b is b

示例2:

// C# program to demonstrate 
// Char.ToLowerInvariant() 
// Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
        // declaring and initializing char variable 
        char c = 'A'; 
  
        // getting Unicode character 
        // using ToLowerInvariant() Method 
        char val = Char.ToLowerInvariant(c); 
  
        // display the char value 
        Console.WriteLine("The lowercase equivalent"+ 
                       " of the {0} is {1}", c, val); 
    } 
}
输出:
The lowercase equivalent of the A is a

参考:



相关用法


注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 C# | Char.ToLowerInvariant(Char) Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。