Int16.IComparable.CompareTo(Object) 方法

定義

比較這個執行個體與指定的物件,並且傳回整數,這個整數表示這個執行個體的值小於、等於或大於物件的值。Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the object.

 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
小於零 (0)Less than zero這個執行個體小於 valueThis instance is less than value.
Zero這個執行個體等於 valueThis instance is equal to value.
大於零 (0)Greater than zero這個執行個體大於 valueThis instance is greater than value.

-或--or-

valuenullvalue is null.

實作

例外狀況

value 不是 Int16value is not an Int16.

備註

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

不論值為何,Int16都會被視為大於 null 參考。An Int16, regardless of its value, is considered greater than a null reference.

適用於