String.CompareOrdinal Method (String, Int32, String, Int32, Int32)
Assembly: mscorlib (in mscorlib.dll)
static member CompareOrdinal : strA:string * indexA:int * strB:string * indexB:int * length:int -> int
The first string to use in the comparison.
The starting index of the substring in strA.
The second string to use in the comparison.
The starting index of the substring in strB.
The maximum number of characters in the substrings to compare.
Return ValueType: System.Int32
A 32-bit signed integer that indicates the lexical relationship between the two comparands.
Less than zero
The substring in strA is less than the substring in strB.
The substrings are equal, or length is zero.
Greater than zero
The substring in strA is greater than the substring in strB.
The indexA, indexB, and length parameters must be nonnegative.
The number of characters compared is the lesser of the length of strA less indexA, the length of strB less indexB, and length.
This method performs a case-sensitive comparison using ordinal sort rules. For more information about word, string, and ordinal sorts, see System.Globalization.CompareOptions. To perform a case-insensitive comparison using ordinal sort rules, call theCompare(String, Int32, String, Int32, Int32, StringComparison)method with the comparisonType argument set toStringComparison.OrdinalIgnoreCase.
Because CompareOrdinal(String, String) is a static method, strA and strB can be null. If both values are null, the method returns 0 (zero), which indicates that strA and strB are equal. If only one of the values is null, the method considers the non-null value to be greater.
Available since 4.5
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1