System Namespace String Class
Compares substrings of two specified String objects, without considering the local national language or culture. Parameters specify the length and starting positions of the substrings.
[ VB ]
<Serializable>
Overloads Public Shared Function CompareOrdinal ( _
ByVal strA As String, _
ByVal indexA As Integer, _
ByVal strB As String, _
ByVal indexB As Integer, _
ByVal length As Integer _
) As Integer
[ C# ]
[ Serializable ]
public static int CompareOrdinal (
string strA,
int indexA,
string strB,
int indexB,
int length
);
[ C++ ]
[ Serializable ]
public: static int CompareOrdinal (
String* strA,
int indexA,
String* strB,
int indexB,
int length
);
[ JScript ]
public Serializable
static function CompareOrdinal (
strA : String,
indexA : int,
strB : String,
indexB : int,
length : int
) : int;
- strA
- The first String.
- indexA
- The starting index of the substring in strA.
- strB
- The second String.
- indexB
- The starting index of the substring in strB.
- length
- The maximum number of characters in the substrings to compare.
A 32-bit signed integer indicating the lexical relationship between the two comparands.
Value Type |
Condition |
Less than zero |
The substring in strA is less than the substring in strB. |
Zero |
The substrings are equal, or length is zero. |
Greater than zero |
The substring in strA is greater than the substring in strB. |
Exception Type |
Condition |
ArgumentOutOfRangeException |
indexA, indexB, or length is negative.
-or-
The sum of indexA and length is greater than strA. Length.
-or-
The sum of indexB and length is greater than strB. Length.
|
By definition, any String, including the empty string, compares greater than a null reference ( Nothing in Visual Basic ); and two null references compare equal to each other.
indexA, indexB, and length must be positive.
The number of characters compared is the lesser of the length of strA less indexA, the length of strB less indexB, and length.
String Members String.CompareOrdinal Overload List Compare CompareTo Int32