Int32.IComparable.CompareTo(Object) 方法

定義

將這個執行個體與指定的物件相比較,並傳回它們的相對值指示。Compares this instance to a specified object and returns an indication of their relative values.

 virtual int System.IComparable.CompareTo(System::Object ^ value) = IComparable::CompareTo;
int IComparable.CompareTo (object value);
Function CompareTo (value As Object) As Integer Implements IComparable.CompareTo

參數

value
Object

要比較的物件或 nullAn object to compare, or null.

傳回

帶正負號的數字,指出這個執行個體與 value 的相對值。A signed number indicating the relative values of this instance and value.

傳回值Return Value說明Description
小於零Less than zero這個執行個體小於 valueThis instance is less than value.
Zero這個執行個體等於 valueThis instance is equal to value.
大於零Greater than zero這個執行個體大於 valueThis instance is greater than value.

-或--or-

valuenullvalue is null.

實作

例外狀況

value 不是 Int32value is not an Int32.

備註

這個成員是明確介面成員實作,This member is an explicit interface member implementation. 只有在 Int32 執行個體轉換成 IConvertible 介面時,才能使用這個成員。It can be used only when the Int32 instance is cast to an IConvertible interface.

任何 Int32的實例(不論其值為何)都會視為大於 nullAny instance of Int32, regardless of its value, is considered greater than null.

適用於