Mega Code Archive

 
Categories / C# Book / 02 Essential Types
 

0249 Determine the order

Syntax: public static int Compare (string strA, string strB, StringComparison comparisonType); public static int Compare (string strA, string strB, bool ignoreCase, CultureInfo culture); public static int Compare (string strA, string strB, bool ignoreCase); public static int CompareOrdinal (string strA, string strB); The return value from those methods tells the order: Value Meaning 0 Equals >0 Before <0 After Let's look at the following example. using System; class Sample { public static void Main() { string s1 = "rntsoft.com"; string s2 = "Rntsoft.com"; Console.WriteLine(s1.CompareTo(s2)); } } The output: -1