

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the HashCode of the tuple in C#?
To get the HashCode of the tuple, the code is as follows −
Example
using System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500, Tuple.Create(50, 100)); var tuple2 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500, Tuple.Create(100, 200)); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); } }
Output
This will produce the following output −
Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = 4621968 HashCode of Tuple2 = 4623530
Example
Let us see another example −
using System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); } }
Output
This will produce the following output −
Is Tuple1 equal to Tuple2? = True HashCode of Tuple1 = 3231587 HashCode of Tuple2 = 3231587
- Related Questions & Answers
- How to get the HashCode for the string in C#?
- How to get the remaining elements of the Tuple in C#?
- Get the HashCode for the current UInt64 instance in C#
- Get the HashCode for the current UInt32 instance in C#
- How to get Sixth Element of the Tuple in C#?
- How to get Third Element of the Tuple in C#?
- How to get Second Element of the Tuple in C#?
- How to get Seventh Element of the Tuple in C#?
- How to get Fifth Element of the Tuple in C#?
- How to get First Element of the Tuple in C#?
- How to get Fourth Element of the Tuple in C#?
- Get the size of the LabelValue Tuple in Java
- The hashCode() method of CopyOnWriteArrayList method in Java
- The hashCode() method of AbstractList class in Java
- Get the Tuple of bytes to step in each dimension when traversing in Numpy
Advertisements