C# String.ToLowerInvariant 方法
C# 中 String.ToLowerInvariant() 方法用于使用不变文化的规则,返回此 String 对象转换为小写的副本。
语法
语法如下 -
public string ToLowerInvariant ();
示例
下面看一个示例 -
using System; using System.Text; public class Demo { public static void Main(String[] args) { string str1 = "Pink Floyd"; string str2 = "Ariana"; Console.WriteLine("String 1 = "+str1); Console.WriteLine("String1 ToLowerInvariant = "+str1.ToLowerInvariant()); Console.WriteLine("String 2 = "+str2); Console.WriteLine("String2 ToLowerInvariant = "+str2.ToLowerInvariant()); Console.WriteLine("String 1 is equal to String 2: {0}", str1.Equals(str2)); } }
输出
String 1 = Pink Floyd String1 ToLowerInvariant = pink floyd String 2 = Ariana String2 ToLowerInvariant = ariana String 1 is equal to String 2: False
示例
现在我们再看另一个示例 -
using System; using System.Text; public class Demo { public static void Main(String[] args) { string str1 = "one"; string str2 = "TWO"; string str3 = "ThrEE"; Console.WriteLine("String 1 = "+str1); Console.WriteLine("String1 ToLowerInvariant = "+str1.ToLowerInvariant()); Console.WriteLine("String 2 = "+str2); Console.WriteLine("String2 ToLowerInvariant = "+str2.ToLowerInvariant()); Console.WriteLine("String 3 = "+str3); Console.WriteLine("String3 ToLowerInvariant = "+str3.ToLowerInvariant()); } }
输出
这将产生以下输出 -
String 1 = one String1 ToLowerInvariant = one String 2 = TWO String2 ToLowerInvariant = two String 3 = ThrEE String3 ToLowerInvariant = three
广告