C#中的Char.ToUpperInvariant(Char)方法

C#中的Char.ToUpperInvariant()方法用于使用不变文化的大小写规则将Unicode字符的值转换为等效的大写形式。

语法

public static char ToUpperInvariant (char ch);

上面的参数ch是要转换的Unicode字符。

现在让我们看一个实现Char.ToUpperInvariant()方法的示例-

示例

using System;
public class Demo {
   public static void Main(){
      char ch = 'q';
      char res = Char.ToUpperInvariant(ch);
      Console.WriteLine("Value = "+ch);
      Console.WriteLine("Uppercase Equivalent = "+res);
   }
}

输出结果

这将产生以下输出-

Value = q
Uppercase Equivalent = Q

现在让我们来看另一个示例-

示例

using System;
public class Demo {
   public static void Main(){
      char ch = 'r';
      char res = Char.ToUpperInvariant(ch);
      Console.WriteLine("Value = "+ch);
      Console.WriteLine("Uppercase Equivalent = "+res);
   }
}

输出结果

这将产生以下输出-

Value = r
Uppercase Equivalent = R