Share via


CompareTo Method

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

Compares this instance to a specified object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than 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:
int CompareTo(
    Object^ value
)
member CompareTo : 
        value:Object -> int 
public function CompareTo(
    value : Object
) : int

Parameters

  • value
    Type: System. . :: . .Object
    An object to compare, or nullNothingnullptrunita null reference (Nothing in Visual Basic).

Return Value

Type: System. . :: . .Int32
One of the following values.

Value

Description

-1

This instance is shorter than value.

0

This instance is equal to value.

1

This instance is longer than value.

-or-

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

Remarks

Any instance of TimeSpan, regardless of its value, is considered greater than null Nothing nullptr unit a null reference (Nothing in Visual Basic) .

The value parameter must be an instance of TimeSpan or null Nothing nullptr unit a null reference (Nothing in Visual Basic) ; otherwise, an exception is thrown.

.NET Framework Security

See Also

Reference

TimeSpan Structure

System Namespace