Instantiation Of a Tuple
Tuple
  • Tuple is a fixed-size collection that can have elements of either same or different data types.
  • It is Similar to arrays.
  • Tuples are allowed to hold up from 1 to 8 elements and if there are more than 8 elements, then the 8th element can be defined as another tuple.
  • Tuples can be specified as parameter or return type of a method.

There are two ways of instantiating a tuple in .net-

-> Through using 'New' operator

Example

Tuple<String, int> t = new Tuple<String, int> ("Hellooo C# Corner", 2);

-> Through using 'Create' factory operator, available in the tuple:

Example

Tuple<int, int, int> t = Tuple.Create<int, int, int> (2, 4, 5);