Boolean.IComparable.CompareTo(Object) 方法

定義

將目前的執行個體與相同類型的另一個物件相比較,並傳回整數,這個整數表示目前的執行個體在排序次序中,位於另一個物件之前、之後或相同位置。Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

 virtual int System.IComparable.CompareTo(System::Object ^ obj) = IComparable::CompareTo;
int IComparable.CompareTo (object obj);
abstract member System.IComparable.CompareTo : obj -> int
override this.System.IComparable.CompareTo : obj -> int
Function CompareTo (obj As Object) As Integer Implements IComparable.CompareTo

參數

obj
Object

要比較的物件。The object to compare.

傳回

Int32

值,表示所比較之物件的相對順序。A value that indicates the relative order of the objects being compared.

實作

備註

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

傳回值具有這些意義:The return value has these meanings:

Value 意義Meaning
小於零 (0)Less than zero 這個執行個體在排序次序中會在 obj 之前。This instance precedes obj in the sort order.
Zero 這個執行個體在排序次序中的位置和 obj 相同。This instance occurs in the same position in the sort order as obj.
大於零 (0)Greater than zero 這個執行個體在排序順序中會跟在 obj 之後。This instance follows obj in the sort order.

適用於