asp.net.ph

String.Compare Method ( String, String )

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;

Parameters

strA
The first String.
strB
The second String.

Return Value

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.

Remarks

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.

See Also

String Members   String.Compare Overload List   Int32   CompareOrdinal   CompareTo Skip Navigation Links


Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note