Tuple<T1,T2,T3,T4,T5>.Equals(Object) メソッド

定義

現在の Tuple<T1,T2,T3,T4,T5> オブジェクトが、指定されたオブジェクトと等しいかどうかを示す値を返します。

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

パラメーター

obj
Object

このインスタンスと比較するオブジェクト。

戻り値

Boolean

現在のインスタンスが指定したオブジェクトと等しい場合は true。それ以外の場合は false

次の例では、2 つのテスト グループの患者の温度に関するデータを含む 5 タプル オブジェクトの配列を定義します。 配列の最初のコンポーネントはテスト グループの数を提供し、2 番目から 5 番目のコンポーネントは 1 時間ごとに患者の温度を提供します。 メソッドはTuple<T1,T2,T3,T4,T5>.Equals(Object)、すべてのオブジェクトを他Tuple<T1,T2,T3,T4,T5>のすべてのTuple<T1,T2,T3,T4,T5>オブジェクトと比較するために呼び出されます。 出力は、オブジェクトの Equals 5 つのコンポーネントすべてが等しい値を持つ場合にのみメソッドがTuple<T1,T2,T3,T4,T5>trueされることを示しています。

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
open System

let 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 = 0 to temperatureInfos.Length - 1 do
    let temperatureInfo = temperatureInfos[ctr]
    for ctr2 = ctr + 1 to temperatureInfos.Length - 1 do
        printfn $"{temperatureInfo} = {temperatureInfos[ctr2]}: {temperatureInfo.Equals temperatureInfos[ctr2]}"
    printfn ""

// 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 パラメーターは、次の条件下で現在のインスタンスと等しいと見なされます。

  • オブジェクトです Tuple<T1,T2,T3,T4,T5>

  • その 5 つのコンポーネントは、現在のインスタンスと同じ型です。

  • その 5 つのコンポーネントは、現在のインスタンスのコンポーネントと同じです。 等しいかどうかは、各コンポーネントの既定のオブジェクトの等値比較子によって判断されます。

適用対象