TimeSpan.CompareTo Method (Object)

 

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)

abstract CompareTo : 
        value:Object -> int
override CompareTo : 
        value:Object -> int

Parameters

value
Type: System.Object

An object to compare, or null.

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 null.

Exception Condition
ArgumentException

value is not a TimeSpan.

Any instance of TimeSpan, regardless of its value, is considered greater than null.

The value parameter must be an instance of TimeSpan or null; otherwise, an exception is thrown.

The following example compares several TimeSpan structures and other objects to a reference TimeSpan structure using the CompareTo method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: