다음을 통해 공유


Tuple<T1,T2,T3>.Equals(Object) 메서드

정의

현재 Tuple<T1,T2,T3> 개체가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

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

이 인스턴스와 비교할 개체입니다.

반환

현재 인스턴스가 지정된 개체와 같으면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 메서드를 Tuple<T1,T2,T3>.Equals(Object) 호출하여 개체 배열의 Tuple<T1,T2,T3> 개체가 서로 같은지 여부를 확인합니다. 출력은 구성 요소의 Equals(Object) 값이 같은 개체를 Tuple<T1,T2,T3> 비교할 때 메서드가 반환 true 된다는 사실을 반영합니다.

using System;

public class Example
{
   public static void Main()
   {
      Tuple<string, double, int>[] scores = 
                      { Tuple.Create("Ed", 78.8, 8),
                        Tuple.Create("Abbey", 92.1, 9), 
                        Tuple.Create("Ed", 71.2, 9),
                        Tuple.Create("Sam", 91.7, 8), 
                        Tuple.Create("Ed", 71.2, 5),
                        Tuple.Create("Penelope", 82.9, 8),
                        Tuple.Create("Ed", 71.2, 9),
                        Tuple.Create("Judith", 84.3, 9) };

      // Test each tuple object for equality with every other tuple.
      for (int ctr = 0; ctr < scores.Length; ctr++)
      {
         var currentTuple = scores[ctr];
         for (int ctr2 = ctr + 1; ctr2 < scores.Length; ctr2++)
            Console.WriteLine("{0} = {1}: {2}", currentTuple, scores[ctr2], 
                                                currentTuple.Equals(scores[ctr2]));      

         Console.WriteLine();
      }   
   }
}
// The example displays the following output;
//    (Ed, 78.8, 8) = (Abbey, 92.1, 9): False
//    (Ed, 78.8, 8) = (Ed, 71.2, 9): False
//    (Ed, 78.8, 8) = (Sam, 91.7, 8): False
//    (Ed, 78.8, 8) = (Ed, 71.2, 5): False
//    (Ed, 78.8, 8) = (Penelope, 82.9, 8): False
//    (Ed, 78.8, 8) = (Ed, 71.2, 9): False
//    (Ed, 78.8, 8) = (Judith, 84.3, 9): False
//    
//    (Abbey, 92.1, 9) = (Ed, 71.2, 9): False
//    (Abbey, 92.1, 9) = (Sam, 91.7, 8): False
//    (Abbey, 92.1, 9) = (Ed, 71.2, 5): False
//    (Abbey, 92.1, 9) = (Penelope, 82.9, 8): False
//    (Abbey, 92.1, 9) = (Ed, 71.2, 9): False
//    (Abbey, 92.1, 9) = (Judith, 84.3, 9): False
//    
//    (Ed, 71.2, 9) = (Sam, 91.7, 8): False
//    (Ed, 71.2, 9) = (Ed, 71.2, 5): False
//    (Ed, 71.2, 9) = (Penelope, 82.9, 8): False
//    (Ed, 71.2, 9) = (Ed, 71.2, 9): True
//    (Ed, 71.2, 9) = (Judith, 84.3, 9): False
//    
//    (Sam, 91.7, 8) = (Ed, 71.2, 5): False
//    (Sam, 91.7, 8) = (Penelope, 82.9, 8): False
//    (Sam, 91.7, 8) = (Ed, 71.2, 9): False
//    (Sam, 91.7, 8) = (Judith, 84.3, 9): False
//    
//    (Ed, 71.2, 5) = (Penelope, 82.9, 8): False
//    (Ed, 71.2, 5) = (Ed, 71.2, 9): False
//    (Ed, 71.2, 5) = (Judith, 84.3, 9): False
//    
//    (Penelope, 82.9, 8) = (Ed, 71.2, 9): False
//    (Penelope, 82.9, 8) = (Judith, 84.3, 9): False
//    
//    (Ed, 71.2, 9) = (Judith, 84.3, 9): False
open System

let scores = 
    [| Tuple.Create("Ed", 78.8, 8)
       Tuple.Create("Abbey", 92.1, 9)
       Tuple.Create("Ed", 71.2, 9)
       Tuple.Create("Sam", 91.7, 8)
       Tuple.Create("Ed", 71.2, 5)
       Tuple.Create("Penelope", 82.9, 8)
       Tuple.Create("Ed", 71.2, 9)
       Tuple.Create("Judith", 84.3, 9) |]

// Test each tuple object for equality with every other tuple.
for ctr = 0 to scores.Length - 1 do
    let currentTuple = scores[ctr]
    for ctr2 = ctr + 1 to scores.Length - 1 do
        printfn $"{currentTuple} = {scores[ctr2]}: {currentTuple.Equals scores[ctr2]}"
    printfn ""

// The example displays the following output
//    (Ed, 78.8, 8) = (Abbey, 92.1, 9): False
//    (Ed, 78.8, 8) = (Ed, 71.2, 9): False
//    (Ed, 78.8, 8) = (Sam, 91.7, 8): False
//    (Ed, 78.8, 8) = (Ed, 71.2, 5): False
//    (Ed, 78.8, 8) = (Penelope, 82.9, 8): False
//    (Ed, 78.8, 8) = (Ed, 71.2, 9): False
//    (Ed, 78.8, 8) = (Judith, 84.3, 9): False
//    
//    (Abbey, 92.1, 9) = (Ed, 71.2, 9): False
//    (Abbey, 92.1, 9) = (Sam, 91.7, 8): False
//    (Abbey, 92.1, 9) = (Ed, 71.2, 5): False
//    (Abbey, 92.1, 9) = (Penelope, 82.9, 8): False
//    (Abbey, 92.1, 9) = (Ed, 71.2, 9): False
//    (Abbey, 92.1, 9) = (Judith, 84.3, 9): False
//    
//    (Ed, 71.2, 9) = (Sam, 91.7, 8): False
//    (Ed, 71.2, 9) = (Ed, 71.2, 5): False
//    (Ed, 71.2, 9) = (Penelope, 82.9, 8): False
//    (Ed, 71.2, 9) = (Ed, 71.2, 9): True
//    (Ed, 71.2, 9) = (Judith, 84.3, 9): False
//    
//    (Sam, 91.7, 8) = (Ed, 71.2, 5): False
//    (Sam, 91.7, 8) = (Penelope, 82.9, 8): False
//    (Sam, 91.7, 8) = (Ed, 71.2, 9): False
//    (Sam, 91.7, 8) = (Judith, 84.3, 9): False
//    
//    (Ed, 71.2, 5) = (Penelope, 82.9, 8): False
//    (Ed, 71.2, 5) = (Ed, 71.2, 9): False
//    (Ed, 71.2, 5) = (Judith, 84.3, 9): False
//    
//    (Penelope, 82.9, 8) = (Ed, 71.2, 9): False
//    (Penelope, 82.9, 8) = (Judith, 84.3, 9): False
//    
//    (Ed, 71.2, 9) = (Judith, 84.3, 9): False
Module Example
   Public Sub Main()
      Dim scores() = 
              { Tuple.Create("Ed", 78.8, 8),
                Tuple.Create("Abbey", 92.1, 9), 
                Tuple.Create("Ed", 71.2, 9),
                Tuple.Create("Sam", 91.7, 8), 
                Tuple.Create("Ed", 71.2, 5),
                Tuple.Create("Penelope", 82.9, 8),
                Tuple.Create("Ed", 71.2, 9),
                Tuple.Create("Judith", 84.3, 9) }

      ' Test each tuple object for equality with every other tuple.
      For ctr As Integer = 0 To scores.Length - 1
         Dim currentTuple = scores(ctr)
         For ctr2 As Integer = ctr + 1 To scores.Length - 1
            Console.WriteLine("{0} = {1}: {2}", currentTuple, scores(ctr2), 
                                                currentTuple.Equals(scores(ctr2)))      
         Next
         Console.WriteLine()
      Next
   End Sub
End Module
' The example displays the following output;
'    (Ed, 78.8, 8) = (Abbey, 92.1, 9): False
'    (Ed, 78.8, 8) = (Ed, 71.2, 9): False
'    (Ed, 78.8, 8) = (Sam, 91.7, 8): False
'    (Ed, 78.8, 8) = (Ed, 71.2, 5): False
'    (Ed, 78.8, 8) = (Penelope, 82.9, 8): False
'    (Ed, 78.8, 8) = (Ed, 71.2, 9): False
'    (Ed, 78.8, 8) = (Judith, 84.3, 9): False
'    
'    (Abbey, 92.1, 9) = (Ed, 71.2, 9): False
'    (Abbey, 92.1, 9) = (Sam, 91.7, 8): False
'    (Abbey, 92.1, 9) = (Ed, 71.2, 5): False
'    (Abbey, 92.1, 9) = (Penelope, 82.9, 8): False
'    (Abbey, 92.1, 9) = (Ed, 71.2, 9): False
'    (Abbey, 92.1, 9) = (Judith, 84.3, 9): False
'    
'    (Ed, 71.2, 9) = (Sam, 91.7, 8): False
'    (Ed, 71.2, 9) = (Ed, 71.2, 5): False
'    (Ed, 71.2, 9) = (Penelope, 82.9, 8): False
'    (Ed, 71.2, 9) = (Ed, 71.2, 9): True
'    (Ed, 71.2, 9) = (Judith, 84.3, 9): False
'    
'    (Sam, 91.7, 8) = (Ed, 71.2, 5): False
'    (Sam, 91.7, 8) = (Penelope, 82.9, 8): False
'    (Sam, 91.7, 8) = (Ed, 71.2, 9): False
'    (Sam, 91.7, 8) = (Judith, 84.3, 9): False
'    
'    (Ed, 71.2, 5) = (Penelope, 82.9, 8): False
'    (Ed, 71.2, 5) = (Ed, 71.2, 9): False
'    (Ed, 71.2, 5) = (Judith, 84.3, 9): False
'    
'    (Penelope, 82.9, 8) = (Ed, 71.2, 9): False
'    (Penelope, 82.9, 8) = (Judith, 84.3, 9): False
'    
'    (Ed, 71.2, 9) = (Judith, 84.3, 9): False

설명

obj 매개 변수는 다음 조건에서 현재 인스턴스와 동일한 것으로 간주됩니다.

  • 개체입니다 Tuple<T1,T2,T3> .

  • 세 가지 구성 요소는 현재 인스턴스와 동일한 형식입니다.

  • 세 가지 구성 요소는 현재 인스턴스의 구성 요소와 같습니다. 같음은 각 구성 요소에 대한 기본 개체 같음 비교자에 의해 결정됩니다.

적용 대상