ValueTuple is a structure introduced in C# 7.0 which represents the value type Tuple. It is already included in .NET Framework 4.7 or higher version. It allows you to store a data set that contains multiple values that may or may not be related to each other.
You can also compare the instance of two value tuples with each other by using CompareTo(ValueTuple<T1, T2, T3>) method. Or in other words, with the help of CompareTo method you are allowed to compare the current ValueTuple<T1, T2, T3> instance to a specified ValueTuple<T1, T2, T3> instance. This method also compares nested value tuples with each other.
public int CompareTo (ValueTuple<T1, T2, T3> other);
Return Type: The return type of this method is System.Int32. And it always returns a signed integer that indicates the relative position of this instance and other in the sort order as shown in the below list:
- Negative integer for the instance precedes another.
- Zero for the instance and other have the same position in the sort order.
- Positive integer for the instance follows another.
Result 1: -1 Result 2: 1 Result 3: 0
Value tuples are equal!!
- Comparing two ValueTuple<T1> in C#
- Comparing two ValueTuple<T1, T2> in C#
- Comparing two ValueTuple<T1, T2, T3, T4, T5> in C#
- Comparing two ValueTuple<T1, T2, T3, T4, T5, T6> in C#
- Comparing two ValueTuple<T1, T2, T3, T4> in C#
- Comparing two ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> in C#
- Difference Between .NET and ASP.NET Framework
- Difference Between Properties and Indexers in C#
- C# Coding Standards
- C# Program to Convert a Binary String to an Integer
- Basics of FileStream in C#
- C# Program for Nested Conditional Operator
- C# Program for Converting Hexadecimal String to Integer
- Program to Input Weekday Number and Print the Weekday 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.