C# | Check if two Tuple Objects are equal Last Updated : 17 Oct, 2022 Comments Improve Suggest changes Like Article Like Report 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: CSharp // C# program to illustrate the // Equals method using System; class GFG { // Main Method static public void Main() { // Taking tuple variables var t1 = Tuple.Create(12, 34, 56, 78); var t2 = Tuple.Create(12, 34, 67, 89); var t3 = Tuple.Create(12, 34, 56, 78); var t4 = Tuple.Create(34, 56, 78); // Check whether the given // tuples are Equal or not // Using Equals() method Console.WriteLine(t1.Equals(t2)); Console.WriteLine(t1.Equals(t3)); Console.WriteLine(t1.Equals(t4)); } } Output:False True False Example 2: CSharp // C# program to illustrate Equals // method with nested tuple using System; class GFG { // Main Method static public void Main() { // Taking Tuples var t1 = Tuple.Create(34, 56, 78, Tuple.Create(12, 34, 56, 78)); var t2 = Tuple.Create(12, 34, 67, 89); var t3 = Tuple.Create(12, 34, 56, Tuple.Create(23, 56)); var t4 = Tuple.Create(34, 56, 78, Tuple.Create(12, 34, 56, 78)); var t5 = Tuple.Create(12, 34, 56, Tuple.Create(24, 56)); // Check whether the given // tuples are Equal or not // Using Equals() method Console.WriteLine(t1.Equals(t2)); Console.WriteLine(t1.Equals(t3)); Console.WriteLine(t1.Equals(t4)); Console.WriteLine(t3.Equals(t5)); Console.WriteLine(t1.Equals(t5)); } } Output:False False True False False Comment More infoAdvertise with us Next Article C# | Check if two Tuple Objects are equal A ankita_saini Follow Improve Article Tags : C# CSharp-Tuple Similar Reads C# | Check if two SortedList objects are equal Equals(Object) Method which is inherited from the Object class is used to check whether the specified SortedList object is equal to another SortedList object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value 2 min read C# | Check if two List objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified List<T> object is equal to another List<T> object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value: 2 min read C# | Check if two ArrayList objects are equal Equals(Object) Method which is inherited from the Object class is used to check whether the specified ArrayList object is equal to another ArrayList object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value: 2 min read C# | Check if two SortedSet<T> objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified SortedSet<T> object is equal to another SortedSet<T> object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Ret 2 min read C# | Check if two OrderedDictionary objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified OrderedDictionary object is equal to another OrderedDictionary object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Retur 2 min read Like