ValueTuple is a structure introduced in C# 7.0 which represents the value type Tuple. It allows you to store a data set which contains multiple values that may or may not be related to each other.
In value tuples, you can check if two value tuples are identical or not by using the ValueTuple.Equals Method. This method will return value which indicates whether the given ValueTuple instance is equal to the specified object or not. It will return true if the given tuples are equal, otherwise, return false. This method can be overloaded in two different ways:
- Equals(ValueTuple) Method
- Equals(Object) Method
The Equals(ValueTuple) method is used to check whether the two ValueTuple instances are equal. It always returns true. The return type of this method is System.Boolean.
public bool Equals (ValueTuple other);
Here, other is a value tuple to compare with the current instance.
Returns: It always returns true.
Is MyTple1 and MyTple2 equal?: True
The Equals(Object) method is used to return a value that determines whether the current ValueTuple instance is equal to a specified object. This method will return true if the given ValueTuple instance is equal to a specified object, otherwise, it will return false.
public override bool Equals (object obj);
Here, obj is the object to compare to the current instance.
Return Type: The return type of this method is System.Boolean.
The given object is equal to the value tuple element...!!
- ValueTuple in C#
- Check if two enums are equal or not in C#
- How to get fifth Element of the ValueTuple in C#?
- How to get First Element of the ValueTuple in C#?
- How to create 4-ValueTuple in C#?
- How to create 3-ValueTuple in C#?
- How to get Second Element of the ValueTuple in C#?
- ValueTuple Struct in C#
- How to compare two ValueTuple in C#?
- How to get third Element of the ValueTuple in C#?
- C# | ValueTuple <T1,T2,T3> Struct
- C# | ValueTuple <T1,T2,T3,T4> Struct
- C# | ValueTuple <T1,T2,T3,T4,T5> Struct
- How to create 2-ValueTuple in C#?
- C# | ValueTuple <T1,T2> Struct
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.