Tuple is a data structure which gives you the easiest way to represent a data set which has multiple values that may/may not be related to each other. Item2 Property is used to get the second element of the given tuple. It is not applicable on 1-Tuple and applicable on all other remaining tuples.
Syntax:
public T2 Item2 { get; }
Here, T2 is the value of the current Tuple<> object’s second component. This Tuple<> can be 2-tuple, or 3-tuple, or 4-tuple, or 5-tuple, or 6-tuple, or 7-tuple, or 8-tuple.
Example: In the below code, you can see that we are accessing the second element of each tuple.
// C# program to illustrate how to get // the second element of the tuple using System; class GFG { // Main method static public void Main() { // Taking 2-tuple var st2 = Tuple.Create("Sohan", 20); Console.WriteLine("Student-2 Age: " + st2.Item2); // Taking 3-tuple var st3 = Tuple.Create("Soniya", 30, "CSE"); Console.WriteLine("Student-3 Age: " + st3.Item2); // Taking 4-tuple var st4 = Tuple.Create("Rohan", 29, "CSE", 2015); Console.WriteLine("Student-4 Age: " + st4.Item2); // Taking 5-tuple var st5 = Tuple.Create("Siya", 22, "CSE", 2017, "20-Mar-1993"); Console.WriteLine("Student-5 Age: " + st5.Item2); // Taking 6-tuple var st6 = Tuple.Create("Riya", 24, "CSE", 2015, "30-May-2015", 230134832); Console.WriteLine("Student-6 Age: " + st6.Item2); // Taking 7-tuple var st7 = Tuple.Create("Rohit", 21, "CSE", 2017, "21-Apr-1998", 384749829, 20000); Console.WriteLine("Student-7 Age: " + st7.Item2); // Taking 8-tuple var st8 = Tuple.Create("Manita", 24, "CSE", 2016, "03-Aug-1991", 235678909, 34000, "C#"); Console.WriteLine("Student-8 Age: " + st8.Item2); } } |
Student-2 Age: 20 Student-3 Age: 30 Student-4 Age: 29 Student-5 Age: 22 Student-6 Age: 24 Student-7 Age: 21 Student-8 Age: 24
Recommended Posts:
- How to create 3-Tuple or Triple Tuple in C#?
- How to create 1-Tuple or Singleton Tuple in C#?
- How to create 2-tuple or pair tuple in C#?
- C# | How to get First Element of the Tuple?
- C# | How to get Third Element of the Tuple?
- C# | How to get Fourth Element of the Tuple?
- C# | How to get Fifth Element of the Tuple?
- C# | How to get Sixth Element of the Tuple?
- C# | How to get Seventh Element of the Tuple?
- How to get Second Element of the ValueTuple in C#?
- C# | How to get the HashCode of the tuple?
- C# | How to get the Remaining Elements of the Tuple?
- C# | Getting the Type of the Tuple's Element
- C# | Tuple
- How to create 4-Tuple or quadruple in C#?
- How to create 5-Tuple or quintuple in C#?
- How to create 6-Tuple in C#?
- How to create 7-Tuple or Septuple in C#?
- How to create 8-Tuple or Octuple in C#?
- C# | Tuple<T1> Class
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

