Compares this instance with a specified object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified object.
- value
- An object that evaluates to a string.
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.
Zero This instance has the same position in the sort order as value.
Greater than zero This instance follows value.
-or-
value is null.
Type Reason ArgumentException value is not a string.
value must be a string object.
The string.CompareTo(object) 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 erload:System.String.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.