When implemented by a class, compares the current instance with another instance of the same type.
[Visual Basic] Function CompareTo( _ ByVal object As Object _ ) As Integer [C#] int CompareTo( object object ); [C++] int CompareTo( Object* object ) = 0; [JScript] function CompareTo( object : Object ) : int;
Value | Condition |
---|---|
a value less than zero | The current instance is less than object. |
zero | The current instance is equal to object. |
a value greater than zero | The current instance is greater than object. |
Exception Type | Condition |
---|---|
ArgumentException | object is not the same type as the current instance. |
a null reference (in Visual Basic Nothing) can always be compared with any other type; therefore, comparisons with a null reference (Nothing) will not generate an exception. When sorting, a null reference (Nothing) is considered to be less than any other object.
IComparable Interface | IComparable Members | System Namespace