Getting the hash code of the ValueTuple in C# Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report ValueTuple.GetHashCode Method is used to get the HashCode of the current ValueTuple instance. It is provided by the ValueTuple struct. Syntax: public override int GetHashCode (); Returns: The return type of this method is System.Int32 and it always returns zero. Example: CSharp // C# program to illustrate how to // find the hash code of the given // value tuples. using System; class GFG { // Main method static public void Main() { // Creating a value tuple with zero element var MyTple1 = ValueTuple.Create(); Console.WriteLine("HashCode of a value tuple with"+ " zero elements: " + MyTple1.GetHashCode()); // Creating a value tuple with one element var MyTple2 = (23); Console.WriteLine("HashCode of a value tuple "+ "with one element: " + MyTple2.GetHashCode()); // Creating a value tuple with two elements var MyTple3 = (56, 45); Console.WriteLine("HashCode of a value tuple "+ "with two elements: " + MyTple3.GetHashCode()); // Creating a value tuple with three elements var MyTple4 = (67, 78, 89); Console.WriteLine("HashCode of a value tuple with "+ "three elements: " + MyTple4.GetHashCode()); // Creating a value tuple with four elements var MyTple5 = (09, 23, 12, 1); Console.WriteLine("HashCode of a value tuple with "+ "four elements: " + MyTple5.GetHashCode()); // Creating a value tuple with five elements var MyTple6 = (65, 87, 98, 23, 45); Console.WriteLine("HashCode of a value tuple with"+ " five elements: " + MyTple6.GetHashCode()); // Creating a value tuple with six elements var MyTple7 = (13, 56, 78, 12, 65, 98); Console.WriteLine("HashCode of a value tuple with"+ " six elements: " + MyTple7.GetHashCode()); // Creating a value tuple with seven elements var MyTple8 = (32, 45, 96, 78, 35, 33, 44); Console.WriteLine("HashCode of a value tuple with"+ " seven elements: " + MyTple8.GetHashCode()); } } Output: HashCode of a value tuple with zero elements: 0 HashCode of a value tuple with one element: 23 HashCode of a value tuple with two elements: -818407567 HashCode of a value tuple with three elements: -1237760639 HashCode of a value tuple with four elements: 2105592814 HashCode of a value tuple with five elements: 695326364 HashCode of a value tuple with six elements: -335480823 HashCode of a value tuple with seven elements: -2111090807 Comment More infoAdvertise with us Next Article How to get third Element of the ValueTuple in C#? A ankita_saini Follow Improve Article Tags : C# CSharp-ValueTuple CSharp-ValueTuple-Methods Similar Reads Getting the Hash Code of the Given Index in C# The Index Structure is introduced in C# 8.0. It represents a type that can be used to index a collection or sequence and it can be started from the start or the end. You are allowed to find the hash code of the specified index with the help of the GetHashCode Method provided by the Index struct. Thi 2 min read Getting the Hash Code of the Specified Range in C# The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to get the hash code of the specified range with the help of the GetHashCode() Method provided by the Range struct. This method returns the hash code of the specified instance. Syntax 2 min read How to get sixth Element of the ValueTuple in C#? 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. Item6 Property is used to get the sixth unnamed element of the given value tuple. It is applicable on e 2 min read How to get third Element of the ValueTuple in C#? 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. Item3 Property is used to get the third unnamed element of the given value tuple. It is applicable on e 2 min read How to get seventh Element of the ValueTuple in C#? 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. Item7 Property is used to get the seventh unnamed element of the given value tuple. It is applicable on 2 min read How to get fifth Element of the ValueTuple in C#? 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. Item5 Property is used to get the fifth unnamed element of the given value tuple. It is applicable on e 2 min read Like