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 | Description |
---|---|
A negative integer | If this instance is less than the object. |
Zero | If this instance and the object are equal. |
A positive integer | If this instance is greater than the object. |
A positive integer | If the object is null. This is a special case. |
Exception Type | Condition |
---|---|
ArgumentException | if the object is not null reference and not a Char. |
In the comparison of two Char values, the Unicode hexadecimal character codes are used to determine the ordering. As a special case, an instance is considered to be greater than a null reference regardless of its value.
The value parameter must be either a Char type or a null reference; otherwise an exception is thrown. Null is considered to be less than this instance.