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 = "java2s.com";
string s2 = "Java2s.com";
Console.WriteLine(s1.CompareTo(s2));
}
}
The output:
-1
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |