System Namespace String Class
Compares two specified String objects.
[ VB ]
<Serializable>
Overloads Public Shared Function Compare ( _
ByVal strA As String, _
ByVal strB As String _
) As Integer
[ C# ]
[ Serializable ]
public static int Compare (
string strA,
string strB
);
[ C++ ]
[ Serializable ]
public: static int Compare (
String* strA,
String* strB
);
[ JScript ]
public Serializable
static function Compare (
strA : String,
strB : String
) : int;
- strA
- The first String.
- strB
- The second String.
A 32-bit signed integer indicating the lexical relationship between the two comparands.
Value |
Meaning |
Less than zero |
strA is less than strB. |
Zero |
strA equals strB. |
Greater than zero |
strA is greater than strB. |
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.
This method performs a case-sensitive operation. The method uses the current culture to determine the ordering of individual characters. Uppercase letters evaluate greater than their lowercase equivalents. The two strings are compared on a character-by-character basis.
String Members String.Compare Overload List Int32 CompareOrdinal CompareTo