Share via


CompareTo Method (Object)

[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 Object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified Object.

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

Syntax

'Declaration
Public Function CompareTo ( _
    value As Object _
) As Integer
public int CompareTo(
    Object value
)
public:
virtual int CompareTo(
    Object^ value
) sealed
abstract CompareTo : 
        value:Object -> int 
override CompareTo : 
        value:Object -> int 
public final function CompareTo(
    value : Object
) : 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 value.

Zero

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

Greater than zero

This instance follows value.

-or-

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

Implements

IComparable. . :: . .CompareTo(Object)

Remarks

value must be a String object.

.NET Framework Security

See Also

Reference

String Class

CompareTo Overload

System Namespace