Mono Class Library: System.DateTime Overview | Members

System.DateTime.CompareTo Method

Returns the sort order of the current instance compared to the specified object . [Edit]

public int CompareTo (object value)

Parameters

value
The object to compare to the current instance. [Edit]

Returns

The return value is a negative number, zero, or a positive number reflecting the sort order of the current instance as compared to value. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:

ValueDescription
A negative numberCurrent instance < value.
ZeroCurrent instance == value.
A positive numberCurrent instance > value, or value is a null reference.
[Edit]

Exceptions

TypeReason
ArgumentExceptionvalue is not a DateTime and is not a null reference. [Edit]

Remarks

Any instance of DateTime, regardless of its value, is considered greater than a null reference.

Note: This method is implemented to support the IComparable interface.

[Edit]

Requirements

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