Mono Class Library: System.String Overview | Members

System.String.CompareTo Method

Returns the sort order of the current instance compared to the specified string. [Edit]

public int CompareTo (string strB)

Parameters

strB
The string to compare to the current instance. [Edit]

Returns

The return value is a negative number, zero, or a positive number reflecting the sort order of the current instance as compared to strB. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:

ValueCondition
A negative numberThe current instance is lexicographically < strB.
ZeroThe current instance is lexicographically == strB.
A positive numberThe current instance is lexicographically > strB, or strB is a null reference.
[Edit]

Remarks

Note:

Uppercase letters evaluate greater than their lowercase equivalents.

The method uses the culture (if any) of the current thread to determine the ordering of individual characters. The two strings are compared on a character-by-character basis.

This method is implemented to support the IComparable<string> interface.

[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0