Last Updated : 11 Jul, 2025
Tupleis 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.
Item5 Propertyis used to get the fifth element of the given tuple. It is not applicable on 1-Tuple, 2-Tuple, 3-Tuple, and 4-Tuple but applicable on all other remaining tuples.
Syntax:public T5 Item5 { get; }
Here,
T5is the value of the current Tuple<> object's fifth component. This Tuple<> can be 5-tuple, or 6-tuple, or 7-tuple, or 8-tuple.
Example:In the below code, you can see that we are accessing the fifth element of each tuple.
CSharp
// C# program to illustrate how to get
// the fifth element of the tuple
using System;
class GFG {
// Main method
static public void Main()
{
// Taking 5-tuple
var st5 = Tuple.Create("Siya", 22, "EEE", 2017,
"20-Mar-1993");
Console.WriteLine("Student-5 DOB: " + st5.Item5);
// Taking 6-tuple
var st6 = Tuple.Create("Riya", 24, "ME", 2015,
"30-May-1991", 230134832);
Console.WriteLine("Student-6 DOB: " + st6.Item5);
// Taking 7-tuple
var st7 = Tuple.Create("Rohit", 21, "IT", 2017,
"21-Apr-1994", 384749829, 20000);
Console.WriteLine("Student-7 DOB: " + st7.Item5);
// Taking 8-tuple
var st8 = Tuple.Create("Manita", 24, "CSE", 2013,
"03-Aug-1991", 235678909, 34000, "C#");
Console.WriteLine("Student-8 DOB: " + st8.Item5);
}
}
Output:
Student-5 DOB: 20-Mar-1993 Student-6 DOB: 30-May-1991 Student-7 DOB: 21-Apr-1994 Student-8 DOB: 03-Aug-1991Note:
You can also get the type of the fifth component of the tuple by using
GetType()method or by using
Type.GetGenericArgumentsmethod.
Example: csharp
// C# program to illustrate how to get the
// type of the fifth element of the tuple
using System;
class GFG{
// Main method
static public void Main (){
// Taking 5-tuple
var stu5 = Tuple.Create("Siya", 22, "CSE",2017,101);
Console.WriteLine("Student-5 ID: "+stu5.Item5);
// Get the type of Item5
// Using GetType() method
Console.WriteLine("Type of Item5: "+stu5.Item5.GetType());
// Get the type of Item5
// Using Type.GetGenericArguments method
Type stu5type = stu5.GetType();
Console.WriteLine("Type of Item5: "+stu5type.GetGenericArguments()[4]);
}
}
Output:
Student-5 ID: 101 Type of Item5: System.Int32 Type of Item5: System.Int32
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4