A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/c-sharp/c-sharp-how-to-get-fourth-element-of-the-tuple/ below:

C# | How to get Fourth Element of the Tuple?

C# | How to get Fourth Element of the Tuple?

Last Updated : 11 Jul, 2025

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.

Item4 Property

is used to get the fourth element of the given tuple. It is not applicable on 1-Tuple, 2-Tuple, and 3-Tuple but applicable on all other remaining tuples.

Syntax:
public T4 Item4 { get; }

Here,

T4

is the value of the current Tuple<> object's fourth component. This Tuple<> can be 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 fourth element of each tuple.

CSharp
// C# program to illustrate how to get 
// the fourth element of the tuple
using System;

class GFG {

    // Main method
    static public void Main()
    {


        // Taking 4-tuple
        var st4 = Tuple.Create("Rohan", 29, "EC", 2015);
        Console.WriteLine("Student-4 Year: " + st4.Item4);

        // Taking 5-tuple
        var st5 = Tuple.Create("Siya", 22, "EEE", 2017,
                                           "20-Mar-1993");

        Console.WriteLine("Student-5 Year: " + st5.Item4);

        // Taking 6-tuple
        var st6 = Tuple.Create("Riya", 24, "ME", 2015,
                               "30-May-2015", 230134832);

        Console.WriteLine("Student-6 Year: " + st6.Item4);

        // Taking 7-tuple
        var st7 = Tuple.Create("Rohit", 21, "IT", 2017, 
                        "21-Apr-1998", 384749829, 20000);

        Console.WriteLine("Student-7 Year: " + st7.Item4);

        // Taking 8-tuple
        var st8 = Tuple.Create("Manita", 24, "CSE", 2016, 
                   "03-Aug-1991", 235678909, 34000, "C#");

        Console.WriteLine("Student-8 Year: " + st8.Item4);
    }
}
Output:
Student-4 Year: 2015
Student-5 Year: 2017
Student-6 Year: 2015
Student-7 Year: 2017
Student-8 Year: 2016


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