此方法用於使用不變區域性的大小寫規則將Unicode字符的值轉換為等效的大寫形式。
用法:
public static char ToUpperInvariant (char c);
在這裏,c是要轉換的Unicode字符。
返回值:如果c已經是大寫或不是字母,則此方法返回c參數的大寫等效項或c的不變值。
以下示例程序旨在說明Char.ToUpperInvariant(Char)方法的用法:
示例1:
// C# program to demonstrate 
// Char.ToUpperInvariant() 
// Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
        // calling get() Method 
        get('A'); 
        get('a'); 
        get('B'); 
        get('b'); 
        get('-'); 
    } 
  
    // Defining get() method 
    public static void get(char c) 
    { 
  
        // getting Unicode character 
        // using ToUpperInvariant() Method 
        char val = Char.ToUpperInvariant(c); 
  
        // display the char value 
        Console.WriteLine("The uppercase equivalent"+ 
                      " of the {0} is {1}", c, val); 
    } 
}
輸出:
The uppercase equivalent of the A is A The uppercase equivalent of the a is A The uppercase equivalent of the B is B The uppercase equivalent of the b is B The uppercase equivalent of the - is -
示例2:
// C# program to demonstrate 
// Char.ToUpperInvariant() 
// Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
        // declaring and intializing char variable 
        char c = 'a'; 
  
        // getting Unicode character 
        // using ToUpperInvariant() Method 
        char val = Char.ToUpperInvariant(c); 
  
        // display the char value 
        Console.WriteLine("The Uppercase equivalent"+ 
                       " of the {0} is {1}", c, val); 
    } 
}
輸出:
The Uppercase equivalent of the a is A
參考:
相關用法
- C# DateTimeOffset.Add()用法及代碼示例
- C# String.Contains()用法及代碼示例
- C# Math.Sin()用法及代碼示例
- C# Math.Cos()用法及代碼示例
- C# Dictionary.Add()用法及代碼示例
- C# Math.Tan()用法及代碼示例
- C# Math.Abs()方法用法及代碼示例
- C# Math.Exp()用法及代碼示例
- C# Math.Abs()函數用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 C# | Char.ToUpperInvariant(Char) Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
