Compares two string regions, starting at specified points that have a specified length, and uses an ordinal comparison.
[Visual Basic] 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#] public static int CompareOrdinal( string strA, int indexA, string strB, int indexB, int length ); [C++] public: static int CompareOrdinal( String* strA, int indexA, String* strB, int indexB, int length ); [JScript] public static function CompareOrdinal( strA : String, indexA : int, strB : String, indexB : int, length : int ) : int;
Permission | Description |
---|---|
A negative integer | If region A is less than region B |
0 | If the two regions are equal |
A positive integer | If region A is greater than region B. |
Exception Type | Condition |
---|---|
ArgumentException | If it is case-insensitive mode for characters greater than 0x80. |
ArgumentNullException | If either string is null. |
ArgumentOutOfRangeException | If the starting positions are less than 0. |
ArgumentOutOfRangeException | If length of the total string is longer than the length of their respective strings. |
The CompareOrdinal method compares two specified strings and returns an integer representation of their relationship with the additiona criteria of the length of the string and the index.
To compare strings under the rules of specified CultureInfo, use Compare or CompareTo
The region of the first string of the specified length, beginning at position of the index for the first string, is compared with the region of the second string of specified length, beginning at postion of the index of the second string, and uses an ordinal comparison. In the comparison of two string objects, a null string is considered less than a non-null string. If both strings are null, they are considered to be equal.
The length parameter must be non-negative. If length is equal to zero (length = 0), then zero is returned. If total length
of the new string is longer than the length of the combined individual strings (indexA + count or indexB + count) that were used to create the new string.
String Class | String Members | System Namespace | String.CompareOrdinal Overload List