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
小于零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.
大于零Greater than zero 此实例在排序顺序中位于 obj 之后。This instance follows obj in the sort order.

适用于