System.TimeSpan.CompareTo Method

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.

Syntax

public int CompareTo (object value)

Parameters

value
An object to compare, or null.

Returns

One of the following values.

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

Exceptions

TypeReason
ArgumentException value is not a TimeSpan and is not a null reference.

Remarks

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.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0