Compare Method
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Compares two specified String objects and returns an integer that indicates their relative position in the sort order.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared Function Compare ( _
strA As String, _
strB As String _
) As Integer
public static int Compare(
string strA,
string strB
)
public:
static int Compare(
String^ strA,
String^ strB
)
static member Compare :
strA:string *
strB:string -> int
public static function Compare(
strA : String,
strB : String
) : int
Parameters
- strA
Type: System. . :: . .String
The first string to compare.
- strB
Type: System. . :: . .String
The second string to compare.
Return Value
Type: System. . :: . .Int32
A 32-bit signed integer that indicates the lexical relationship between the two comparands.
Value |
Condition |
---|---|
Less than zero |
strA is less than strB. |
Zero |
strA equals strB. |
Greater than zero |
strA is greater than strB. |
Remarks
The comparison uses the current culture to obtain culture-specific information such as casing rules and the alphabetic order of individual characters. For example, a culture could specify that certain combinations of characters be treated as a single character, or uppercase and lowercase characters be compared in a particular way, or that the sorting order of a character depends on the characters that precede or follow it.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.