Tuple<T1,T2,T3,T4,T5>.Equals(Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 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
이 인스턴스와 비교할 개체입니다.
반환
현재 인스턴스가 지정된 개체와 같으면 true
이고, 그렇지 않으면 false
입니다.
예제
다음 예제에서는 2개의 시험 단에 있는 환자의 온도에 관하여 데이터를 포함하는 5개의 튜플 개체의 배열을 정의합니다. 배열의 첫 번째 구성 요소는 테스트 그룹의 수를 제공하며, 두 번째 구성 요소에서 다섯 번째 구성 요소는 매시간 간격으로 환자의 온도를 제공합니다. 메서드 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개 구성 요소는 현재 인스턴스의 구성 요소와 같습니다. 같음은 각 구성 요소에 대한 기본 개체 같음 비교자에 의해 결정됩니다.