Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>.Equals(Object) Method

Definition

Gibt einen Wert zurück, der angibt, ob das aktuelle Tuple<T1,T2,T3,T4,T5,T6,T7,TRest>-Objekt gleich einem angegebenen Objekt ist.Returns a value that indicates whether the current Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> object is equal to a specified object.

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

Parameters

obj
Object

Das Objekt, das mit dieser Instanz verglichen werden soll.The object to compare with this instance.

Returns

Boolean

true, wenn die aktuelle Instanz gleich dem angegebenen Objekt ist, andernfalls false.true if the current instance is equal to the specified object; otherwise, false.

Examples

Im folgenden Beispiel werden fünf Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> Objekte definiert, die Primzahlen enthalten.The following example defines five Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> objects that contain prime numbers. Anschließend vergleicht er das erste-Objekt mit jedem der restlichen Objekte.It then compares the first object with each of the remaining objects. Wie die Ausgabe zeigt, sind nur die ersten und letzten Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> Objekte gleich, da Sie über eine identische Anzahl von Komponenten mit identischen Werten verfügen.As the output shows, only the first and the last Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> objects are equal, because they have an identical number of components with identical values.

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

Remarks

Der obj-Parameter wird als gleich der aktuellen Instanz betrachtet, wenn er alle folgenden Bedingungen erfüllt:The obj parameter is considered to be equal to the current instance if it meets all the following conditions:

  • Es handelt sich um ein Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> Objekt.It is a Tuple<T1,T2,T3,T4,T5,T6,T7,TRest> object.

  • Sie verfügt über die gleiche Gesamtzahl von Komponenten, die denselben Typ wie die aktuelle Instanz haben.It has the same total number of components that are of the same types as the current instance.

  • Die Komponenten (einschließlich der zugehörigen Komponenten) entsprechen denen der aktuellen Instanz.Its components (including its nested components) are equal to those of the current instance. Gleichheit wird durch den Standard Gleichheits Vergleich für jede Komponente bestimmt.Equality is determined by the default equality comparer for each component.

Applies to