Tuple<T1,T2,T3,T4,T5>.Equals(Object) Tuple<T1,T2,T3,T4,T5>.Equals(Object) Tuple<T1,T2,T3,T4,T5>.Equals(Object) Tuple<T1,T2,T3,T4,T5>.Equals(Object) Method

定義

現在の Tuple<T1,T2,T3,T4,T5> オブジェクトが、指定されたオブジェクトと等しいかどうかを示す値を返します。Returns a value that indicates whether the current Tuple<T1,T2,T3,T4,T5> object is equal to a specified object.

public:
 override bool Equals(System::Object ^ obj);
public override bool Equals (object obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean

パラメーター

obj
Object Object Object Object

このインスタンスと比較するオブジェクト。The object to compare with this instance.

戻り値

現在のインスタンスが指定したオブジェクトと等しい場合は true。それ以外の場合は falsetrue if the current instance is equal to the specified object; otherwise, false.

次の例では、2 つのテスト グループの患者の温度データを含んだ 5 タプル オブジェクトの配列を定義します。The following example defines an array of 5-tuple objects that contain data about the temperatures of patients in two test groups. 配列の最初のコンポーネントは、テスト グループの数を提供し、2 番目 5 番目のコンポーネントからが 1 時間ごとに、患者の温度を提供します。The first component of the array provides the number of the test group, and the second through fifth components provide the temperatures of a patient at hourly intervals. Tuple<T1,T2,T3,T4,T5>.Equals(Object)を比較するメソッドが呼び出されたすべてTuple<T1,T2,T3,T4,T5>で他のすべてのオブジェクトTuple<T1,T2,T3,T4,T5>オブジェクト。The Tuple<T1,T2,T3,T4,T5>.Equals(Object) method is called to compare every Tuple<T1,T2,T3,T4,T5> object with every other Tuple<T1,T2,T3,T4,T5> object. 出力を示していますが、Equalsメソッドを返します。true場合にのみの 5 つのコンポーネントをすべて、Tuple<T1,T2,T3,T4,T5>オブジェクトが同じ値を持ちます。The output illustrates that the Equals method returns true only when all five components of the Tuple<T1,T2,T3,T4,T5> objects have equal values.

using System;

public class Class1
{
   public static void Main()
   {
      Tuple<int, double, double, double, double>[] temperatureInfos = 
                           { Tuple.Create(2, 97.9, 97.8, 98.0, 98.2),
                             Tuple.Create(1, 98.6, 98.8, 98.8, 99.0), 
                             Tuple.Create(2, 98.6, 98.6, 98.6, 98.4),
                             Tuple.Create(1, 98.4, 98.6, 99.0, 99.2),
                             Tuple.Create(2, 98.6, 98.6, 98.6, 98.4),
                             Tuple.Create(1, 98.6, 98.8, 98.8, 99.0) }; 
      // Compare each item with every other item for equality.
      for (int ctr = 0; ctr < temperatureInfos.Length; ctr++)
      {
         var temperatureInfo = temperatureInfos[ctr];
         for (int ctr2 = ctr + 1; ctr2 < temperatureInfos.Length; ctr2++)
            Console.WriteLine("{0} = {1}: {2}", temperatureInfo, temperatureInfos[ctr2], 
                                                temperatureInfo.Equals(temperatureInfos[ctr2]));
         Console.WriteLine();
      }   
   }
}
// The example displays the following output:
//    (2, 97.9, 97.8, 98, 98.2) = (1, 98.6, 98.8, 98.8, 99): False
//    (2, 97.9, 97.8, 98, 98.2) = (2, 98.6, 98.6, 98.6, 98.4): False
//    (2, 97.9, 97.8, 98, 98.2) = (1, 98.4, 98.6, 99, 99.2): False
//    (2, 97.9, 97.8, 98, 98.2) = (2, 98.6, 98.6, 98.6, 98.4): False
//    (2, 97.9, 97.8, 98, 98.2) = (1, 98.6, 98.8, 98.8, 99): False
//    
//    (1, 98.6, 98.8, 98.8, 99) = (2, 98.6, 98.6, 98.6, 98.4): False
//    (1, 98.6, 98.8, 98.8, 99) = (1, 98.4, 98.6, 99, 99.2): False
//    (1, 98.6, 98.8, 98.8, 99) = (2, 98.6, 98.6, 98.6, 98.4): False
//    (1, 98.6, 98.8, 98.8, 99) = (1, 98.6, 98.8, 98.8, 99): True
//    
//    (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.4, 98.6, 99, 99.2): False
//    (2, 98.6, 98.6, 98.6, 98.4) = (2, 98.6, 98.6, 98.6, 98.4): True
//    (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.6, 98.8, 98.8, 99): False
//    
//    (1, 98.4, 98.6, 99, 99.2) = (2, 98.6, 98.6, 98.6, 98.4): False
//    (1, 98.4, 98.6, 99, 99.2) = (1, 98.6, 98.8, 98.8, 99): False
//    
//    (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.6, 98.8, 98.8, 99): False
Module Example
   Public Sub Main()
      Dim temperatureInfos() = 
             { Tuple.Create(2, 97.9, 97.8, 98.0, 98.2), 
               Tuple.Create(1, 98.6, 98.8, 98.8, 99.0),  
               Tuple.Create(2, 98.6, 98.6, 98.6, 98.4), 
               Tuple.Create(1, 98.4, 98.6, 99.0, 99.2), 
               Tuple.Create(2, 98.6, 98.6, 98.6, 98.4), 
               Tuple.Create(1, 98.6, 98.8, 98.8, 99.0) } 
      ' Compare each item with every other item for equality.
      For ctr As Integer = 0 To temperatureInfos.Length - 1
         Dim temperatureInfo = temperatureInfos(ctr)
         For ctr2 As Integer = ctr + 1 To temperatureInfos.Length - 1
            Console.WriteLine("{0} = {1}: {2}", temperatureInfo, temperatureInfos(ctr2), 
                                                temperatureInfo.Equals(temperatureInfos(ctr2)))
         Next  
         Console.WriteLine()                                               
      Next
   End Sub
End Module
' The example displays the following output:
'    (2, 97.9, 97.8, 98, 98.2) = (1, 98.6, 98.8, 98.8, 99): False
'    (2, 97.9, 97.8, 98, 98.2) = (2, 98.6, 98.6, 98.6, 98.4): False
'    (2, 97.9, 97.8, 98, 98.2) = (1, 98.4, 98.6, 99, 99.2): False
'    (2, 97.9, 97.8, 98, 98.2) = (2, 98.6, 98.6, 98.6, 98.4): False
'    (2, 97.9, 97.8, 98, 98.2) = (1, 98.6, 98.8, 98.8, 99): False
'    
'    (1, 98.6, 98.8, 98.8, 99) = (2, 98.6, 98.6, 98.6, 98.4): False
'    (1, 98.6, 98.8, 98.8, 99) = (1, 98.4, 98.6, 99, 99.2): False
'    (1, 98.6, 98.8, 98.8, 99) = (2, 98.6, 98.6, 98.6, 98.4): False
'    (1, 98.6, 98.8, 98.8, 99) = (1, 98.6, 98.8, 98.8, 99): True
'    
'    (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.4, 98.6, 99, 99.2): False
'    (2, 98.6, 98.6, 98.6, 98.4) = (2, 98.6, 98.6, 98.6, 98.4): True
'    (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.6, 98.8, 98.8, 99): False
'    
'    (1, 98.4, 98.6, 99, 99.2) = (2, 98.6, 98.6, 98.6, 98.4): False
'    (1, 98.4, 98.6, 99, 99.2) = (1, 98.6, 98.8, 98.8, 99): False
'    
'    (2, 98.6, 98.6, 98.6, 98.4) = (1, 98.6, 98.8, 98.8, 99): False

注釈

objパラメーターは、次の条件下で現在のインスタンスと等しいと見なされます。The obj parameter is considered to be equal to the current instance under the following conditions:

  • Tuple<T1,T2,T3,T4,T5>オブジェクト。It is a Tuple<T1,T2,T3,T4,T5> object.

  • 5 つのコンポーネントでは、現在のインスタンスと同じ型です。Its five components are of the same types as the current instance.

  • 5 つのコンポーネントは、現在のインスタンスのと同じです。Its five components are equal to those of the current instance. 等しいかどうかは、各コンポーネントの既定のオブジェクトの等値比較子によって判断されます。Equality is determined by the default object equality comparer for each component.

適用対象