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)

'Declaration
Public Shared Function Compare ( _
	strA As String, _
	strB As String _
) As Integer

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.

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.

Show: