Compares this instance to the 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 | Condition |
---|---|
A negative integer | If this instance is less than the object. |
A zero (0) | If this instance and the object have the same value. |
A positive integer | If this instance is greater than the object . |
A positive integer | If the object is a null reference (in Visual Basic Nothing). This is a special case. |
When comparing two Int32 values, canonical ordering is used. As a special case, regardless of its value, an instance is considered to be greater than a null object reference.
You should use the CompareTo method instead of subtraction because very large negative numbers will wrap to positive.
The value parameter must be either an Int32 type or a null object reference.