String.CompareTo Method (Object)
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System.Object
An Object that evaluates to a String.
Return Value
Type: System.Int32A 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.
Value | Condition |
|---|---|
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. |
Implements
IComparable.CompareTo(Object)| Exception | Condition |
|---|---|
| ArgumentException | value is not a String. |
value must be a String object.
Caution: |
|---|
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.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Caution: