Share via


CompareTo Method (String)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Compares this instance with a specified String object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified String.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Function CompareTo ( _
    strB As String _
) As Integer
public int CompareTo(
    string strB
)
public:
int CompareTo(
    String^ strB
)
member CompareTo : 
        strB:string -> int 
public function CompareTo(
    strB : String
) : int

Parameters

Return Value

Type: System. . :: . .Int32
A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter.

Value

Condition

Less than zero

This instance precedes strB.

Zero

This instance has the same position in the sort order as strB.

Greater than zero

This instance follows strB.

-or-

strB is nullNothingnullptrunita null reference (Nothing in Visual Basic).

.NET Framework Security

See Also

Reference

String Class

CompareTo Overload

System Namespace