Mono Class Library: System.String Overview | Members

System.String.CompareOrdinal Method

Compares substrings of two specified string objects based on the code points of the contained Unicode characters. [Edit]

public static int CompareOrdinal (string strA, int indexA, string strB, int indexB, int length)

Parameters

strA
The first string to compare. [Edit]
indexA
A int containing the starting index of the substring in strA. [Edit]
strB
The second string to compare. [Edit]
indexB
A int containing the starting index of the substring in strB. [Edit]
length
A int containing the number of characters in the substrings to compare. [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:

Value TypeCondition
A negative numberThe substring in strA is < the substring in strB, or strA is a null reference.
ZeroThe substring in strA == the substring in strB, or both strA and strB are null references.
A positive numberThe substring in strA is > the substring in strB, or strB is a null reference.
[Edit]

Exceptions

TypeReason
ArgumentOutOfRangeException

indexA is greater than strA .Length

-or-

indexB is greater than strB .Length

-or-

indexA, indexB, or lengthis negative.

[Edit]

Remarks

When either of the String arguments is the null reference an ArgumentOutOfRangeException shall be thrown if the corresponding index is non-zero.

Note:

The maximum number of characters compared is the lesser of the length of strA less indexA, the length of strB less indexB, and length.

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. Upper case 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