NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

String.Compare (String, Int32, String, Int32, Int32, Boolean)

Compares two strings with default CultureInfo information.

[Visual Basic]
Overloads Public Shared Function Compare( _
   ByVal strA As String, _
   ByVal indexA As Integer, _
   ByVal strB As String, _
   ByVal indexB As Integer, _
   ByVal length As Integer, _
   ByVal ignoreCase As Boolean _
) As Integer
[C#]
public static int Compare(
   string strA,
   int indexA,
   string strB,
   int indexB,
   int length,
   bool ignoreCase
);
[C++]
public: static int Compare(
   String* strA,
   int indexA,
   String* strB,
   int indexB,
   int length,
   bool ignoreCase
);
[JScript]
public static function Compare(
   strA : String,
   indexA : int,
   strB : String,
   indexB : int,
   length : int,
   ignoreCase : Boolean
) : int;

Parameters

strA
The first string.
indexA
The index into the first string at which the region begins.
strB
The second string
indexB
The index into the second string at which the region begins.
length
The length of the regions to compare.
ignoreCase
true indicates that the comparison is case-insensitive.

Return Value

Value Type Condition
A negative integer If region A is less than region B.
0 If the two regions or length are equal.
A positive integer If region A is greater than region B.
true If the comparison is case-insensitive.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException If either string is null.
ArgumentOutOfRangeException If either index is out of range.
ArgumentOutOfRangeException If the length to compare is negative.

Remarks

The Compare method does a locale sensitive comparison of two strings and returns a integer representation of their relationship with the specific culture information from CultureInfo, but also returns a Boolean about the strings case-sensitivity.

One string may be "less than" or "greater than" another string depending upon the rules of the national language under which the comparison is made. To compare strings without regard to national languages, see CompareOrdinal.

The region of the first string of specified length, beginning at the specified position for the first string, is compared with the region of the second of a specified length, beginning at the specified position for the second string. The default locale is used.

The length parameter must be non-negative. If length equals zero (length = 0), then zero is returned.

See Also

String Class | String Members | System Namespace | String.Compare Overload List | Int32