How to get Seventh Element of the Tuple in C#?

CsharpServer Side ProgrammingProgramming

<p>To get seventh element of the Tuple, the code is as follows &minus;</p><h2>Example</h2><p><a class="demo" href="http://tpcg.io/xuJzMPH2" rel="nofollow" target="_blank">&nbsp;Live Demo</a></p><pre class="prettyprint notranslate">using System; public class Demo { &nbsp; &nbsp;public static void Main(String[] args) { &nbsp; &nbsp; &nbsp; var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); &nbsp; &nbsp; &nbsp; var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Is Tuple1 equal to Tuple2? = &quot;+tuple1.Equals(tuple2)); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;HashCode of Tuple1 = &quot;+tuple1.GetHashCode()); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;HashCode of Tuple2 = &quot;+tuple2.GetHashCode()); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple1 Item 1st = &quot;+tuple1.Item1); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple2 Item 1st = &quot;+tuple2.Item1); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple1 Item 2nd = &quot;+tuple1.Item2); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple2 Item 2nd = &quot;+tuple2.Item2); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple1 Item 4th = &quot;+tuple1.Item4); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple2 Item 4th = &quot;+tuple2.Item4); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple1 Item 5th = &quot;+tuple1.Item5); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple2 Item 5th = &quot;+tuple2.Item5); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple1 Item 6th = &quot;+tuple1.Item6); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple2 Item 5th = &quot;+tuple2.Item6); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple1 Item 7th = &quot;+tuple1.Item7); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple2 Item 7th = &quot;+tuple2.Item7); &nbsp; &nbsp;} }</pre><h2>Output</h2><p>This will produce the following output &minus;</p><pre class="result notranslate">Is&nbsp;Tuple1&nbsp;equal&nbsp;to&nbsp;Tuple2?&nbsp;=&nbsp;True HashCode&nbsp;of&nbsp;Tuple1&nbsp;=&nbsp;3231587 HashCode&nbsp;of&nbsp;Tuple2&nbsp;=&nbsp;3231587 Tuple1&nbsp;Item&nbsp;1st&nbsp;=&nbsp;75 Tuple2&nbsp;Item&nbsp;1st&nbsp;=&nbsp;75 Tuple1&nbsp;Item&nbsp;2nd&nbsp;=&nbsp;200 Tuple2&nbsp;Item&nbsp;2nd&nbsp;=&nbsp;200 Tuple1&nbsp;Item&nbsp;4th&nbsp;=&nbsp;700 Tuple2&nbsp;Item&nbsp;4th&nbsp;=&nbsp;700 Tuple1&nbsp;Item&nbsp;5th&nbsp;=&nbsp;100 Tuple2&nbsp;Item&nbsp;5th&nbsp;=&nbsp;100 Tuple1&nbsp;Item&nbsp;6th&nbsp;=&nbsp;1200 Tuple2&nbsp;Item&nbsp;5th&nbsp;=&nbsp;1200 Tuple1&nbsp;Item&nbsp;7th&nbsp;=&nbsp;1500 Tuple2&nbsp;Item&nbsp;7th&nbsp;=&nbsp;1500</pre><h2>Example</h2><p>Let us see another example &minus;</p><p><a class="demo" href="http://tpcg.io/XMYqiRrk" rel="nofollow" target="_blank">&nbsp;Live Demo</a></p><pre class="prettyprint notranslate">using System; public class Demo { &nbsp; &nbsp;public static void Main(String[] args) { &nbsp; &nbsp; &nbsp; var tuple = Tuple.Create(1200, 1500, 2200, 2700, 3100, 3500, 4500, 5500); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;HashCode of Tuple = &quot;+tuple.GetHashCode()); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple Item 1st = &quot;+tuple.Item1); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple Item 2nd = &quot;+tuple.Item2); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple Item 3rd = &quot;+tuple.Item3); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple Item 4th = &quot;+tuple.Item4); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple Item 5th = &quot;+tuple.Item5); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple Item 6th = &quot;+tuple.Item6); &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Tuple Item 7th = &quot;+tuple.Item7); &nbsp; &nbsp;} }</pre><h2>Output</h2><p>This will produce the following output &minus;</p><pre class="result notranslate">HashCode&nbsp;of&nbsp;Tuple&nbsp;=&nbsp;49989024 Tuple&nbsp;Item&nbsp;1st&nbsp;=&nbsp;1200 Tuple&nbsp;Item&nbsp;2nd&nbsp;=&nbsp;1500 Tuple&nbsp;Item&nbsp;3rd&nbsp;=&nbsp;2200 Tuple&nbsp;Item&nbsp;4th&nbsp;=&nbsp;2700 Tuple&nbsp;Item&nbsp;5th&nbsp;=&nbsp;3100 Tuple&nbsp;Item&nbsp;6th&nbsp;=&nbsp;3500 Tuple&nbsp;Item&nbsp;7th&nbsp;=&nbsp;4500</pre>
raja
Updated on 05-Dec-2019 12:06:35

Advertisements