May 19, 2010

Comparing Strings


String MyString = "Hello World";
String OtherString = "Hello World!";
int MyInt = MyString.CompareTo(OtherString);    
Console.WriteLine( MyInt );

this example displays 1 to the console.All overloads
 of the String.CompareTo  method perform culture-sensitive
 and case-sensitive comparisons by default. No overloads of 
this method are provided that allow you to perform a 
culture-insensitive comparison. For code clarity, it is 
recommended that you use the String.Compare method 
instead,

No comments:

Post a Comment