In C#, a singleton tuple is a tuple which contains only one element and singleton tuple is also known as 1-tuple. You can create a 1-tuple using two different ways:
- Using Tuple<T1>(T1) Constructor
- Using the Create method
Using Tuple<T1>(T1) Constructor
You can create a singleton tuple using Tuple <T1>(T1) constructor. It initializes a new instance of the Tuple<T1> class. But when you create a tuple using this constructor then you have to specify the type of the element stored in the tuple.
public Tuple (T1 item1);
Here, item1 is the value of the tuple’s only component.
Using Create Method
You can also create a singleton 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.
public static Tuple<T1> Create<T1> (T1 item1);
Here, item1 is the value of the tuple element and T1 is the type of the element stored in the tuple.
Return Type: This method returns the components of the singleton tuple whose value is item1.
- How to create 2-tuple or pair tuple in C#?
- How to create 3-Tuple or Triple Tuple in C#?
- How to create 6-Tuple in C#?
- How to create 8-Tuple or Octuple in C#?
- How to create 7-Tuple or Septuple in C#?
- How to create 5-Tuple or quintuple in C#?
- How to create 4-Tuple or quadruple in C#?
- C# | Tuple
- C# | Tuple<T1,T2,T3,T4> Class
- C# | Tuple Class
- C# | Tuple<T1> Class
- C# | How to get Fifth Element of the Tuple?
- C# | Tuple<T1,T2,T3> Class
- C# | How to get Third Element of the Tuple?
- C# | Tuple<T1,T2,T3,T4,T5,T6,T7> Class
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.