# Tuple<T1,T2,T3,T4,T5,T6>.IComparable.CompareTo(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

#### 戻り値

Int32

Value 説明Description

ゼロZero このインスタンスと `obj` の位置は、並べ替え順序において同じです。This instance and `obj` have the same position in the sort order.

#### 例外

`obj`Tuple<T1,T2,T3,T4,T5,T6> オブジェクトではありません。`obj` is not a Tuple<T1,T2,T3,T4,T5,T6> object.

## 例

``````using System;

public class Example
{
public static void Main()
{
// Create array of sextuple with population data for three U.S.
// cities, 1960-2000.
Tuple<string, int, int, int, int, int>[] cities =
{ Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820),
Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278),
Tuple.Create("Chicago", 3550904, 3366957, 3005072, 2783726, 2896016) };

// Display array in unsorted order.
Console.WriteLine("In unsorted order:");
foreach (var city in cities)
Console.WriteLine(city.ToString());

Console.WriteLine();

Array.Sort(cities);

// Display array in sorted order.
Console.WriteLine("In sorted order:");
foreach (var city in cities)
Console.WriteLine(city.ToString());
}
}
// The example displays the following output:
//    In unsorted order:
//    (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820)
//    (New York, 7781984, 7894862, 7071639, 7322564, 8008278)
//    (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016)
//
//    In sorted order:
//    (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016)
//    (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820)
//    (New York, 7781984, 7894862, 7071639, 7322564, 8008278)
``````
``````Module Example
Public Sub Main()
' Create array of sextuple with population data for three U.S.
' cities, 1960-2000.
Dim cities() =
{ Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820),
Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278),
Tuple.Create("Chicago", 3550904, 3366957, 3005072, 2783726, 2896016) }

' Display array in unsorted order.
Console.WriteLine("In unsorted order:")
For Each city In cities
Console.WriteLine(city.ToString())
Next
Console.WriteLine()

Array.Sort(cities)

' Display array in sorted order.
Console.WriteLine("In sorted order:")
For Each city In cities
Console.WriteLine(city.ToString())
Next
End Sub
End Module
' The example displays the following output:
'    In unsorted order:
'    (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820)
'    (New York, 7781984, 7894862, 7071639, 7322564, 8008278)
'    (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016)
'
'    In sorted order:
'    (Chicago, 3550904, 3366957, 3005072, 2783726, 2896016)
'    (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820)
'    (New York, 7781984, 7894862, 7071639, 7322564, 8008278)
``````

## 注釈

このメンバーは、明示的なインターフェイス メンバーの実装です。This member is an explicit interface member implementation. これは、Tuple<T1,T2,T3,T4,T5,T6> のインスタンスが IComparable インターフェイスにキャストされる場合のみ、使用できます。It can be used only when the Tuple<T1,T2,T3,T4,T5,T6> instance is cast to an IComparable interface.

このメソッドは、 IComparable.CompareTo クラスの実装を提供し Tuple<T1,T2,T3,T4,T5,T6> ます。This method provides the IComparable.CompareTo implementation for the Tuple<T1,T2,T3,T4,T5,T6> class. メソッドは直接呼び出すことができますが、通常は、コレクションのメンバーを並べ替えるために、やなどのコレクションの並べ替えメソッドの既定のオーバーロードによって呼び出され 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.

IComparable.CompareToメソッドは、並べ替え操作で使用することを目的としています。The IComparable.CompareTo method is intended for use in sorting operations. 比較の主な目的が2つのオブジェクトが等しいかどうかを判断する場合は、この値を使用しないでください。It should not be used when the primary purpose of a comparison is to determine whether two objects are equal. 2つのオブジェクトが等しいかどうかを判断するには、メソッドを呼び出し Tuple<T1,T2,T3,T4,T5,T6>.Equals(Object) ます。To determine whether two objects are equal, call the Tuple<T1,T2,T3,T4,T5,T6>.Equals(Object) method.

メソッドは、 IComparable.CompareTo(Object) 既定のオブジェクト比較子を使用して、各コンポーネントを比較します。The IComparable.CompareTo(Object) method uses the default object comparer to compare each component.