

- 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
Getting the Type of the Tuple’s Element in C#
<p style="">To get the type of the Tuple’s element, the code is as follows −</p><h2>Example</h2><p><a class="demo" href="http://tpcg.io/I1UrwSQG" rel="nofollow" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate" style="">using System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(150, 1500, Tuple.Create(50, 100)); var tuple2 = Tuple.Create(150, 1500, Tuple.Create(100, 200)); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple1.GetType()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple2.GetType()); } }</pre><h2>Output</h2><p>This will produce the following output −</p><pre class="result notranslate">Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = 188892 Type of Tuple1 = System.Tuple`3[System.Int32,System.Int32,System.Tuple`2[System.Int32,System.Int32]] HashCode of Tuple2 = 191462 Type of Tuple1 = System.Tuple`3[System.Int32,System.Int32,System.Tuple`2[System.Int32,System.Int32]]</pre><h2>Example</h2><p>Let us now see another example −</p><p><a class="demo" href="http://tpcg.io/yQrp4Mzj" rel="nofollow" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate" style="">using System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(10, 20); var tuple2 = Tuple.Create(30, 40); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple1.GetType()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple2.GetType()); } }</pre><h2>Output</h2><p>This will produce the following output −</p><pre class="result notranslate">Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = 350 Type of Tuple1 = System.Tuple`2[System.Int32,System.Int32] HashCode of Tuple2 = 1014 Type of Tuple1 = System.Tuple`2[System.Int32,System.Int32]</pre>
- Related Questions & Answers
- Getting the type of the current 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#?
- Tuple Data Type in Python
- How do we set the type of element in HTML?
- Align an element with the bottom of the parent element's font in Bootstrap 4
- Align an element with the top of the parent element's font in Bootstrap 4
- How to specify the language of the element's content in HTML?
- How to set an element's display type with JavaScript?
- Python Getting sublist element till N
Advertisements