String.CompareTo Method (Object)
Assembly: mscorlib (in mscorlib.dll)
abstract CompareTo : value:Object -> int override CompareTo : value:Object -> int
Return ValueType: System.Int32
A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter.
Less than zero
This instance precedes value.
This instance has the same position in the sort order as value.
Greater than zero
This instance follows value.
value is a null reference (Nothing in Visual Basic).
value must be a String object.
The CompareTo method was designed primarily for use in sorting or alphabetizing operations. It should not be used when the primary purpose of the method call is to determine whether two strings are equivalent. To determine whether two strings are equivalent, call the Equals method.
This method performs a word (case-sensitive and culture-sensitive) comparison using the current culture. For more information about word, string, and ordinal sorts, see System.Globalization.CompareOptions.
For more information about the behavior of this method, see the Remarks section of the String.Compare(String, String) method.Notes to Callers
Character sets include ignorable characters. The CompareTo method does not consider such characters when it performs a culture-sensitive comparison. For example, if the following code is run on the .NET Framework 4 or later, a comparison of "animal" with "ani-mal" (using a soft hyphen, or U+00AD) indicates that the two strings are equivalent.
To recognize ignorable characters in a string comparison, call the CompareOrdinal(String, String) method.