A RetroSearch Logo

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

Search Query:

Showing content from https://www.geeksforgeeks.org/c-sharp/how-to-create-4-tuple-or-quadruple-in-c-sharp/ below:

How to create 4-Tuple or quadruple in C#?

How to create 4-Tuple or quadruple in C#?

Last Updated : 11 Jul, 2025

In C#, a 4-tuple is a

tuple

that contains four elements and it is also known as

quadruple

. You can create a 4-tuple using two different ways:

Using Tuple<T1,T2,T3,T4>(T1, T2, T3, T4) Constructor

You can create 4-tuple using Tuple<T1, T2, T3, T4>(T1, T2, T3, T4) constructor. It initializes a new instance of the Tuple<T1, T2, T3, T4> class. But when you create a tuple using this constructor then

you have to specify the type of the element

stored in the tuple.

Syntax:
public Tuple (T1 item1, T2 item2, T3 item3, T4 item4);
Parameters: Example: CSharp
// C# program to create 4-tuple
// using the tuple constructor
using System;

public class GFG {

    // Main method
    static public void Main()
    {

        // Creating tuple with four elements
        // Using Tuple<T1, T2, T3, T4>(T1, 
        // T2, T3, t4) constructor
        Tuple<string, int, char, double> My_Tuple = new Tuple<string,
                  int, char, double>("GeeksforGeeks", 10, 'G', 20.4);

        Console.WriteLine("Element 1: " + My_Tuple.Item1);
        Console.WriteLine("Element 2: " + My_Tuple.Item2);
        Console.WriteLine("Element 3: " + My_Tuple.Item3);
        Console.WriteLine("Element 4: " + My_Tuple.Item4);
    }
}
Output:
Element 1: GeeksforGeeks
Element 2: 10
Element 3: G
Element 4: 20.4
Using Create Method

You can also create 4-tuple with the help of Create method. When you use this method then

there is no need to specify the type of the elements

stored in the tuple.

Syntax:
public static Tuple<T1,T2,T3,T4> Create<T1, T2, T3, T4> (T1 item1, T2 item2, T3 item3, T4 item4);
Type Parameters: Parameters: Return Type:

This method returns 4-tuple whose value is

item1, item2

,

item3

, and

item4

.

Example: CSharp
// C# program to create 4-tuple
// using create method
using System;

public class GFG {

    // Main method
    static public void Main()
    {

        // Creating tuple with four elements
        // Using Create method
        var My_Tuple = Tuple.Create("Geeks", 20, 'f', 340.6);

        Console.WriteLine("Element 1: " + My_Tuple.Item1);
        Console.WriteLine("Element 2: " + My_Tuple.Item2);
        Console.WriteLine("Element 3: " + My_Tuple.Item3);
        Console.WriteLine("Element 4: " + My_Tuple.Item4);
    }
}
Output:
Element 1: Geeks
Element 2: 20
Element 3: f
Element 4: 340.6
Reference:

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