Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Equals(Object) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve um valor que indica se o objeto atual Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> é igual a um objeto especificado.
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
Parâmetros
- obj
- Object
O objetivo a comparar com este caso.
Devoluções
true se a instância atual for igual ao objeto especificado; caso contrário, false.
Exemplos
O exemplo seguinte define cinco Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> objetos que contêm números primos. Depois compara o primeiro objeto com cada um dos objetos restantes. Como a saída mostra, apenas o primeiro e o último Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> objeto são iguais, porque têm um número idêntico de componentes com valores idênticos.
using System;
public class Class1
{
public static void Main()
{
// Create five 8-tuple objects containing prime numbers.
var prime1 = new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (2, 3, 5, 7, 11, 13, 17,
new Tuple<Int32>(19));
var prime2 = new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (23, 29, 31, 37, 41, 43, 47,
new Tuple<Int32>(55));
var prime3 = new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (3, 2, 5, 7, 11, 13, 17,
new Tuple<Int32>(19));
var prime4 = new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32, Int32>> (2, 3, 5, 7, 11, 13, 17,
new Tuple<Int32, Int32>(19, 23));
var prime5 = new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (2, 3, 5, 7, 11, 13, 17,
new Tuple<Int32>(19));
Console.WriteLine("{0} = {1} : {2}", prime1, prime2, prime1.Equals(prime2));
Console.WriteLine("{0} = {1} : {2}", prime1, prime3, prime1.Equals(prime3));
Console.WriteLine("{0} = {1} : {2}", prime1, prime4, prime1.Equals(prime4));
Console.WriteLine("{0} = {1} : {2}", prime1, prime5, prime1.Equals(prime5));
}
}
// The example displays the following output:
// (2, 3, 5, 7, 11, 13, 17, 19) = (23, 29, 31, 37, 41, 43, 47, 55) : False
// (2, 3, 5, 7, 11, 13, 17, 19) = (3, 2, 5, 7, 11, 13, 17, 19) : False
// (2, 3, 5, 7, 11, 13, 17, 19) = (2, 3, 5, 7, 11, 13, 17, 19, 23) : False
// (2, 3, 5, 7, 11, 13, 17, 19) = (2, 3, 5, 7, 11, 13, 17, 19) : True
open System
// Create five 8-tuple objects containing prime numbers.
let prime1 =
new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (2, 3, 5, 7, 11, 13, 17,
new Tuple<Int32>(19))
let prime2 =
new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (23, 29, 31, 37, 41, 43, 47,
new Tuple<Int32>(55))
let prime3 =
new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (3, 2, 5, 7, 11, 13, 17,
new Tuple<Int32>(19))
let prime4 =
new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32, Int32>> (2, 3, 5, 7, 11, 13, 17,
new Tuple<Int32, Int32>(19, 23))
let prime5 =
new Tuple<Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple<Int32>> (2, 3, 5, 7, 11, 13, 17,
new Tuple<Int32>(19))
printfn $"{prime1} = {prime2} : {prime1.Equals prime2}"
printfn $"{prime1} = {prime3} : {prime1.Equals prime3}"
printfn $"{prime1} = {prime4} : {prime1.Equals prime4}"
printfn $"{prime1} = {prime5} : {prime1.Equals prime5}"
// The example displays the following output:
// (2, 3, 5, 7, 11, 13, 17, 19) = (23, 29, 31, 37, 41, 43, 47, 55) : False
// (2, 3, 5, 7, 11, 13, 17, 19) = (3, 2, 5, 7, 11, 13, 17, 19) : False
// (2, 3, 5, 7, 11, 13, 17, 19) = (2, 3, 5, 7, 11, 13, 17, 19, 23) : False
// (2, 3, 5, 7, 11, 13, 17, 19) = (2, 3, 5, 7, 11, 13, 17, 19) : True
Module Example
Public Sub Main()
' Create five 8-tuple objects containing prime numbers.
Dim prime1 = New Tuple(Of Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple(Of Int32)) (2, 3, 5, 7, 11, 13, 17,
New Tuple(Of Int32)(19))
Dim prime2 = New Tuple(Of Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple(Of Int32)) (23, 29, 31, 37, 41, 43, 47,
New Tuple(Of Int32)(55))
Dim prime3 = New Tuple(Of Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple(Of Int32)) (3, 2, 5, 7, 11, 13, 17,
New Tuple(Of Int32)(19))
Dim prime4 = New Tuple(Of Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple(Of Int32, Int32)) (2, 3, 5, 7, 11, 13, 17,
New Tuple(Of Int32, Int32)(19, 23))
Dim prime5 = New Tuple(Of Int32, Int32, Int32, Int32, Int32, Int32, Int32,
Tuple(Of Int32)) (2, 3, 5, 7, 11, 13, 17,
New Tuple(Of Int32)(19))
Console.WriteLine("{0} = {1} : {2}", prime1, prime2, prime1.Equals(prime2))
Console.WriteLine("{0} = {1} : {2}", prime1, prime3, prime1.Equals(prime3))
Console.WriteLine("{0} = {1} : {2}", prime1, prime4, prime1.Equals(prime4))
Console.WriteLine("{0} = {1} : {2}", prime1, prime5, prime1.Equals(prime5))
End Sub
End Module
' The example displays the following output:
' (2, 3, 5, 7, 11, 13, 17, 19) = (23, 29, 31, 37, 41, 43, 47, 55) : False
' (2, 3, 5, 7, 11, 13, 17, 19) = (3, 2, 5, 7, 11, 13, 17, 19) : False
' (2, 3, 5, 7, 11, 13, 17, 19) = (2, 3, 5, 7, 11, 13, 17, 19, 23) : False
' (2, 3, 5, 7, 11, 13, 17, 19) = (2, 3, 5, 7, 11, 13, 17, 19) : True
Observações
O obj parâmetro é considerado igual à instância atual se cumprir todas as seguintes condições:
É um Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> objeto.
Tem o mesmo número total de componentes que são do mesmo tipo que a instância atual.
Os seus componentes (incluindo os componentes aninhados) são iguais aos da instância atual. A igualdade é determinada pelo comparador de igualdade por defeito para cada componente.