Compares this instance to a specified object.
[Visual Basic] Overridable Public Function CompareTo( _ ByVal value As Object _ ) As Integer [C#] public virtual int CompareTo( object value ); [C++] public: virtual int CompareTo( Object* value ); [JScript] public function CompareTo( value : Object ) : int;
Value Type | Condition |
---|---|
A negative integer | If this instance is less than the value. |
Zero | If this instance and the value have the same value. |
A positive integer | If this instance is greater than the value. |
A positive integer | If the value is a null reference (in Visual Basic Nothing). This is a special case. |
Exception Type | Condition |
---|---|
ArgumentException | If the value is not a DateTime. |
The CompareTo method implements CompareTo. When comparing two DateTime values, the number of ticks is used to determine the ordering.
The value parameter that is compared must be another DateTime or a null reference.
As a special case, an instance, regardless of its value, is considered to be greater than a null reference.
DateTime Structure | DateTime Members | System Namespace | Object | IComparable