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-tuple-6-class/ below:

C# Tuple<T1,T2,T3,T4,T5,T6> Class - GeeksforGeeks

C# Tuple<T1,T2,T3,T4,T5,T6> Class

Last Updated : 11 Jul, 2025

Tuple<T1, T2, T3, T4, T5, T6> class creates a 6-tuple or sextuple. It represents a tuple that contains six elements. You can instantiate a Tuple<T1, T2, T3, T4, T5, T6> object by calling either the Tuple<T1, T2, T3, T4, T5, T6>(T1, T2, T3, T4, T5, T6) constructor or by the static Tuple.Create method.

Constructor
Tuple<T1, T2, T3, T4, T5, T6>(T1, T2, T3, T4, T5, T6)
Property

We can retrieve value of Tuple<T1, T2, T3, T4, T5, T6>(T1, T2, T3, T4, T5, T6) object by read-only Item<elementNumber> instance property.

Example: Creating six tuples using the tuple class constructor

C#
// Using constructor and property of 
// Tuple<T1, T2, T3, T4, T5, T6> Class
using System;

class Geeks
{
	static public void Main()
	{
		// Creating 6-Tuple using constructor
		Tuple<int, int, int, string, int, string> tuple = 
          new Tuple<int, int, int, string, int, string>
          	(79, 34, 67, "Geeks", 44, "GeeksforGeeks");

		// Accessing the values
		Console.WriteLine("Value of the First Component: " + tuple.Item1);
		Console.WriteLine("Value of the Second Component: " + tuple.Item2);
		Console.WriteLine("Value of the Third Component: " + tuple.Item3);
		Console.WriteLine("Value of the Fourth Component: " + tuple.Item4);
		Console.WriteLine("Value of the Fifth Component: " + tuple.Item5);
		Console.WriteLine("Value of the Sixth Component: " + tuple.Item6);
	}
}
Output:
Value of the First Component: 79
Value of the Second Component: 34
Value of the Third Component: 67
Value of the Fourth Component: Geeks
Value of the Fifth Component: 44
Value of the Sixth Component: GeeksforGeeks
Methods

Method

Description

Equals(Object)

Returns a value that indicates whether the current Tuple<T1, T2, T3, T4, T5, T6> object is equal to a specified object.

GetHashCode()

Returns the hash code for the current Tuple<T1, T2, T3, T4, T5, T6> object.

GetType()

Gets the Type of the current instance.

MemberwiseClone()

Creates a shallow copy of the current Object.

ToString()

Returns a string that represents the value of this Tuple<T1, T2, T3, T4, T5, T6> instance.

Example: Demonstration of Equals() Method.

C#
// Using the tuple Equals() method
using System;

class Geeks
{
	static public void Main()
	{

		// Creating 6-Tuple
		// Using Tuple<T1, T2, T3, T4, T5, 
		// T6>(T1, T2, T3, T4, T5, T6) constructor
		Tuple<int, int, int, int, int, int> mytuple1 = new Tuple<int,
		int, int, int, int, int>(20, 40, 90, 89, 33, 66);

		Tuple<int, int, int, int, int, int> mytuple2 = new Tuple<int,
		int, int, int, int, int>(20, 40, 90, 89, 33, 66);

		// Using Equals method
		if (mytuple1.Equals(mytuple2))
			Console.WriteLine("Tuple Matched.");
		else
			Console.WriteLine("Tuple not Matched.");
	}
}


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