字符串比较的常用函数
static void Main(string[] arg) { int int1 = 0; int int2 = 0; int int3 = 0; string str1 = "adf"; string str2 = "adf"; string str3 = "Adf"; string str4 = "Bdf"; string str5 = ""; //比较字符串的常用函数: //(1) == //(2) Int Compare(string strA,string strB); //(3) Int Compare(string strA,string strB,bool IgorCase)//忽略大小写 //(4) public Int CompareTo(string strB ); //(5) public bool Equals(string value) // public static bool Equals(string a, string b) //练习1 Console.WriteLine(str1 == str2); //练习2 Console.WriteLine(string.Compare("aaa", "aaa")); Console.WriteLine(string.Compare("aaa", "bbb")); Console.WriteLine(string.Compare("bbb", "aaa")); //练习3 Console.WriteLine(string.Compare("aaa", "aAa", true)); Console.WriteLine(string.Compare("aaa", "aAa", false)); //练习4 Console.WriteLine(str1.CompareTo(str2)); //练习5 Console.WriteLine(str1.Equals(str2)); Console.WriteLine(string.Equals(str1, str2)); Console.ReadKey(); }