VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-check-if-two-tuple-objects-are-equal/

⇱ C# | Check if two Tuple Objects are equal - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Check if two Tuple Objects are equal

Last Updated : 11 Jul, 2025

A tuple is a data structure which gives you the easiest way to represent a data set. You can also check if the given tuple object is equal to the specified object or not using the Equals Method. This method will return true if the given tuple object is equal to the specified object, otherwise, return false. 

Syntax:

public override bool Equals (object obj);

Here, obj is the object to compare with this instance. 

Return Type: The return type of this method is Boolean. Means it will return true if the tuple object is equal to the given object. Otherwise, return false

Important Points: This obj parameter is considered to be equal when it meets the following conditions:

  • If it is a Tuple<> object. Here Tuple<> is may be of 1-tuple, or 2-tuple, or 3-tuple, or 4-tuple, or 5-tuple, or 6-tuple, or 7-tuple, or 8-tuple.
  • It must contain the same number of elements that are of the same types as the current instance.
  • Its elements (including its nested components) are equal to those of the current instance. The equality is determined by the default equality comparer for each element.

Below programs illustrate the use of the above-discussed method: 

Example 1: 

Output:
False
True
False

Example 2: 

Output:
False
False
True
False
False
Comment
Article Tags:
Article Tags:

Explore