ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>.IComparable.CompareTo(Object) ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>.IComparable.CompareTo(Object) ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>.IComparable.CompareTo(Object) Method

定义

比较当前 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 对象与指定对象,并返回一个整数,该整数指示当前对象在排序顺序中的位置:是在指定对象之前、之后还是在与指定对象相同的位置。Compares the current ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> object to a specified object and returns an integer that indicates whether the current object is before, after, or in the same position as the specified object in the sort order.

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

参数

other
Object Object Object

要与当前实例进行比较的对象。An object to compare with the current instance.

返回

一个带符号整数,指示此实例和 obj 在排序顺序中的相对位置,如下表所示。A signed integer that indicates the relative position of this instance and obj in the sort order, as shown in the following table.

Value 描述Description
负整数A negative integer 此实例位于 other 之前。This instance precedes other.
Zero 此实例在排序顺序中的位置与 other 相同。This instance and other have the same position in the sort order.
正整数A positive integer 此实例位于 other 之后。This instance follows other.

实现

异常

注解

此成员是显式的接口成员实现。This member is an explicit interface member implementation. 它只能在 ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> 实例强制转换为 IComparable 接口时使用。It can be used only when the ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> instance is cast to an IComparable interface.

此方法提供IComparable.CompareTo实现ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>结构。This method provides the IComparable.CompareTo implementation for the ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest> structure. 虽然可以直接调用该方法,最常调用的集合进行排序的默认重载方法,如Array.Sort(Array)SortedList.Add、 集合的成员进行排序。Although the method can be called directly, it is most commonly called by the default overloads of collection-sorting methods, such as Array.Sort(Array) and SortedList.Add, to order the members of a collection.

注意

ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>.IComparable.CompareTo方法应在排序操作中使用。The ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>.IComparable.CompareTo method is intended for use in sorting operations. 它不应比较的主要目的在于确定两个对象是否相等。It should not be used when the primary purpose of a comparison is to determine whether two objects are equal. 若要确定两个对象,调用ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Equals(Object)方法。To determine whether two objects are equal, call the ValueTuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Equals(Object) method.

此方法使用的默认对象比较器比较每个组件。This method uses the default object comparer to compare each component.

适用于