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

정의

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

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입니다.

예제

다음 예제에서는 1960년부터 2000년까지 로스앤젤레스와 뉴욕의 인구 데이터를 포함하는 sextuples 배열을 정의합니다. 각 sextuple의 첫 번째 구성 요소는 도시를 식별합니다. 첫 번째, 세 번째 및 네 번째 sextuples는 뉴욕에 대한 데이터를 포함합니다. 첫 번째 섹스 튜플은 네 번째 sextuple의 중복입니다. 세 번째 sextuple은 도시를 "뉴욕"이 아닌 "뉴욕시"로 식별합니다. 예제에서와 같이 네 번째 sextuple만 첫 번째 sextuple과 같습니다.

using System;

public class Example
{
   public static void Main()
   {
      // Get population data for New York City and Los Angeles, 1960-2000.
      Tuple<string, int, int, int, int, int>[] urbanPopulations =
           { Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278),
             Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820),
             Tuple.Create("New York City", 7781984, 7894862, 7071639, 7322564, 8008278),
             Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) };
      // Compare each tuple with every other tuple for equality.
      for (int ctr = 0; ctr <= urbanPopulations.Length - 2; ctr++)
      {                      
         var urbanPopulation = urbanPopulations[ctr];
         Console.WriteLine(urbanPopulation.ToString() + " = ");
         for (int innerCtr = ctr +1; innerCtr <= urbanPopulations.Length - 1; innerCtr++)
            Console.WriteLine("   {0}: {1}", urbanPopulations[innerCtr], 
                              urbanPopulation.Equals(urbanPopulations[innerCtr]));
         Console.WriteLine();
      }   
   }
}
// The example displays the following output:
//    (New York, 7781984, 7894862, 7071639, 7322564, 8008278) =
//       (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820): False
//       (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False
//       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): True
//    
//    (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) =
//       (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False
//       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False
//    
//    (New York City, 7781984, 7894862, 7071639, 7322564, 8008278) =
//       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False
open System

// Get population data for New York City and Los Angeles, 1960-2000.
let urbanPopulations =
    [| Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278)
       Tuple.Create("Los Angeles", 2479015, 2816061, 2966850, 3485398, 3694820)
       Tuple.Create("New York City", 7781984, 7894862, 7071639, 7322564, 8008278)
       Tuple.Create("New York", 7781984, 7894862, 7071639, 7322564, 8008278) |]
// Compare each tuple with every other tuple for equality.
for ctr = 0 to urbanPopulations.Length - 2 do
    let urbanPopulation = urbanPopulations[ctr]
    printfn $"{urbanPopulation} = "
    for innerCtr = ctr + 1 to urbanPopulations.Length - 1 do
        printfn $"   {urbanPopulations[innerCtr]}: {urbanPopulation.Equals urbanPopulations[innerCtr]}"
    printfn ""
// The example displays the following output:
//    (New York, 7781984, 7894862, 7071639, 7322564, 8008278) =
//       (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820): False
//       (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False
//       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): True
//    
//    (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) =
//       (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False
//       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False
//    
//    (New York City, 7781984, 7894862, 7071639, 7322564, 8008278) =
//       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False
Module Example
   Public Sub Main()
      ' Get population data for New York City and Los Angeles, 1960-2000.
      Dim urbanPopulations() =
           { Tuple.Create("New York", 7781984, 7894862, 
                          7071639, 7322564, 8008278),
             Tuple.Create("Los Angeles", 2479015, 2816061, 
                          2966850, 3485398, 3694820),
             Tuple.Create("New York City", 7781984, 7894862, 
                          7071639, 7322564, 8008278),
             Tuple.Create("New York", 7781984, 7894862, 
                          7071639, 7322564, 8008278) }
      ' Compare each tuple with every other tuple for equality.
      For ctr As Integer = 0 To urbanPopulations.Length - 2                      
         Dim urbanPopulation = urbanPopulations(ctr)
         Console.WriteLine(urbanPopulation.ToString() + " = ")
         For innerCtr As Integer = ctr + 1 To urbanPopulations.Length - 1
            Console.WriteLine("   {0}: {1}", urbanPopulations(innerCtr), _
                              urbanPopulation.Equals(urbanPopulations(innerCtr)))
         Next
         Console.WriteLine()
      Next
   End Sub
End Module
' The example displays the following output:
'    (New York, 7781984, 7894862, 7071639, 7322564, 8008278) =
'       (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820): False
'       (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False
'       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): True
'    
'    (Los Angeles, 2479015, 2816061, 2966850, 3485398, 3694820) =
'       (New York City, 7781984, 7894862, 7071639, 7322564, 8008278): False
'       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False
'    
'    (New York City, 7781984, 7894862, 7071639, 7322564, 8008278) =
'       (New York, 7781984, 7894862, 7071639, 7322564, 8008278): False

설명

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

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

  • 6개의 구성 요소는 현재 인스턴스와 동일한 형식입니다.

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

적용 대상