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, String, Boolean, CultureInfo)

Compares two strings with locale specific information.

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

Parameters

strA
The first string.
strB
The second string.
ignoreCase
true indicates that the comparison is case-insensitive.
culture
Sets the locale.

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
ArgumentNullException If either string is null.

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 and CurrentCulture.

The comparison of strA and strB is case-insensitive if ignoreCase is true. The locale is set by culture. This method does a locale-sensitive comparison.

See Also

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