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.
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.
Importatnt Points: This obj parameter is considered to be equal when it meets the following conditions:
- If it 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:
False True False
False False True False False
- C# | Check if two SortedList objects are equal
- C# | Check if two ListDictionary objects are equal
- C# | Check if two HashSet<T> objects are equal
- C# | Check if two BitArray objects are equal
- C# | Check if two LinkedList<T> objects are equal
- C# | Check if two List objects are equal
- C# | Check if two SortedSet<T> objects are equal
- C# | Check if two StringDictionary objects are equal or not
- C# | Check if two StringCollection objects are equal
- C# | Check if two OrderedDictionary objects are equal
- C# | Check if two HybridDictionary objects are equal
- Check if two Dictionary objects are equal in C#
- Check if two SortedDictionary objects are equal in C#
- C# | Check if two StringBuilder objects are Equal
- C# | Check if two ArrayList objects are equal
- How to create 3-Tuple or Triple Tuple in C#?
- How to create 1-Tuple or Singleton Tuple in C#?
- How to create 2-tuple or pair tuple in C#?
- C# | Check if two String objects have the same value | Set-1
- Check if two enums are equal or not in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai