Mono Class Library: System.String Overview | Members

System.String.Compare Method

Compares two string objects in a case-sensitive manner. [Edit]

public static int Compare (string strA, string strB)

Parameters

strA
The first string to compare. Can be a null reference. [Edit]
strB
The second string to compare. Can be a null reference. [Edit]

Returns

The return value is a negative number, zero, or a positive number reflecting the sort order of the specified strings. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:

ValueMeaning
A negative numberstrA is lexicographically < strB.
ZerostrA is lexicographically == strB.
A positive numberstrA is lexicographically > strB.
[Edit]

Remarks

This method performs a case-sensitive operation.

Note:

The result of comparing any string (including the empty string) to a null reference is greater than zero. The result of comparing two null references is zero. 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.

[Edit]

Requirements

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