Compares this instance of the object to another specified object.
[Visual Basic] Overridable Public Function CompareTo( _ ByVal obj As Object _ ) As Integer [C#] public virtual int CompareTo( object obj ); [C++] public: virtual int CompareTo( Object* obj ); [JScript] public function CompareTo( obj : Object ) : int;
Value | Condition |
---|---|
A negative integer | If this instance is false and the object is true. |
Zero | If this instance and the object have the same value. |
A positive integer | If this instance is true and the object is false. |
A positive integer | If the object is null. This is a special case. |
Exception Type | Condition |
---|---|
ArgumentException | If the object is not a Boolean and is not null. |
The CompareTo method compares this object to another object and returns an integer that indicates the relationship. For Booleans, false sorts before true.
When comparing two Boolean values, false is considered to be less than true. As a special case, a null reference is considered less than any instance.
The object parameter must be either a Boolean type or a null reference.
Boolean Structure | Boolean Members | System Namespace | Object