

- 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 remaining elements of the Tuple in C#?
<p>To get the remaining elements of the Tuple, the Rest property is used. The code is as follows −</p><h2>Example</h2><p><a class="demo" href="http://tpcg.io/JKNmyIM9" rel="nofollow noopener noreferrer" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate">using System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500, 2000); var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500, 2000); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Tuple1 Item 1st = "+tuple1.Item1); Console.WriteLine("Tuple2 Item 1st = "+tuple2.Item1); Console.WriteLine("Tuple1 Item 2nd = "+tuple1.Item2); Console.WriteLine("Tuple2 Item 2nd = "+tuple2.Item2); Console.WriteLine("Tuple1 Item 4th = "+tuple1.Item4); Console.WriteLine("Tuple2 Item 4th = "+tuple2.Item4); Console.WriteLine("Tuple1 Item 5th = "+tuple1.Item5); Console.WriteLine("Tuple2 Item 5th = "+tuple2.Item5); Console.WriteLine("Tuple1 Item 6th = "+tuple1.Item6); Console.WriteLine("Tuple2 Item 6th = "+tuple2.Item6); Console.WriteLine("Tuple1 Item 7th = "+tuple1.Item7); Console.WriteLine("Tuple2 Item 7th = "+tuple2.Item7); Console.WriteLine("Tuple1 rest value = "+tuple1.Rest); Console.WriteLine("Tuple2 rest value = "+tuple2.Rest); } }</pre><h2>Output</h2><p>This will produce the following output −</p><pre class="result notranslate">Is Tuple1 equal to Tuple2? = True HashCode of Tuple1 = 3247155 HashCode of Tuple2 = 3247155 Tuple1 Item 1st = 75 Tuple2 Item 1st = 75 Tuple1 Item 2nd = 200 Tuple2 Item 2nd = 200 Tuple1 Item 4th = 700 Tuple2 Item 4th = 700 Tuple1 Item 5th = 100 Tuple2 Item 5th = 100 Tuple1 Item 6th = 1200 Tuple2 Item 6th = 1200 Tuple1 Item 7th = 1500 Tuple2 Item 7th = 1500 Tuple1 rest value = (2000) Tuple2 rest value = (2000)</pre><h2>Example</h2><p>Let us now see another example −</p><p><a class="demo" href="http://tpcg.io/PcP4zb2o" 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(75, 200, 500, 700, 100, 1200, 1500, Tuple.Create("AB", 2000, "CD")); var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500, Tuple.Create(2500, 3500, 4000, "XY")); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Tuple1 Item 1st = "+tuple1.Item1); Console.WriteLine("Tuple2 Item 1st = "+tuple2.Item1); Console.WriteLine("Tuple1 Item 2nd = "+tuple1.Item2); Console.WriteLine("Tuple2 Item 2nd = "+tuple2.Item2); Console.WriteLine("Tuple1 Item 4th = "+tuple1.Item4); Console.WriteLine("Tuple2 Item 4th = "+tuple2.Item4); Console.WriteLine("Tuple1 Item 5th = "+tuple1.Item5); Console.WriteLine("Tuple2 Item 5th = "+tuple2.Item5); Console.WriteLine("Tuple1 Item 6th = "+tuple1.Item6); Console.WriteLine("Tuple2 Item 6th = "+tuple2.Item6); Console.WriteLine("Tuple1 Item 7th = "+tuple1.Item7); Console.WriteLine("Tuple2 Item 7th = "+tuple2.Item7); Console.WriteLine("Tuple1 rest value = "+tuple1.Rest); Console.WriteLine("Tuple2 rest value = "+tuple2.Rest); } }</pre><h2>Output</h2><p>This will produce the following output −</p><pre class="result notranslate" style="">Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = -1121878415 HashCode of Tuple2 = -835095725 Tuple1 Item 1st = 75 Tuple2 Item 1st = 75 Tuple1 Item 2nd = 200 Tuple2 Item 2nd = 200 Tuple1 Item 4th = 700 Tuple2 Item 4th = 700 Tuple1 Item 5th = 100 Tuple2 Item 5th = 100 Tuple1 Item 6th = 1200 Tuple2 Item 6th = 1200 Tuple1 Item 7th = 1500 Tuple2 Item 7th = 1500 Tuple1 rest value = ((AB, 2000, CD)) Tuple2 rest value = ((2500, 3500, 4000, XY))</pre>
- Related Questions & Answers
- Element equal to the sum of all the remaining elements in C++
- How to get the HashCode of the tuple 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 days remaining in current year in Java
- How to get unique elements in nested tuple in Python
- Get the size of the LabelValue Tuple in Java
- Check if the array has an element which is equal to sum of all the remaining elements in Python
- PyTorch – How to get the exponents of tensor elements?
- Raise elements of tuple as power to another tuple in Python
Advertisements