Tuples in c#

Posted By : Bipul Kumar Tiwari,

A tuple is a data structure that has a specific number and sequence of elements. It is an ordered sequence, immutable, fixed size of heterogeneous objects.

Ordered sequence:

           The order of items in a tuple follows the order used at the time of its creation.

Immutable:

          All properties are read-only tuple, i.e., once created, it cannot be changed.

Fixed Size:

           The size is set at the time of its creation. If it was created with three items, you cannot add new items.

heterogeneous objects:

          Each item has a specific and independent of the type of the other item.

Tuples are commonly used in four ways:


The static class Tuple provides 8 overloads Create methods to create Tuple of size 1 to 8.

Methods Name Description
Create<T1>(T1) Create a new 1-tuple, or singleton.
Create<T1, T2>(T1, T2) Create a new 2-tuple, or pair.
Create<T1, T2, T3>(T1, T2, T3) Create a new 3-tuple, or triple.
Create<T1, T2, T3, T4>(T1, T2, T3, T4) Create a new 4-tuple, or quadruple.
Create<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5) Create a new 5-tuple, or quintuple.
Create<T1, T2, T3, T4, T5, T6>(T1, T2, T3, T4, T5, T6) Create a new 6-tuple, or sextuple.
Create<T1, T2, T3, T4, T5, T6, T7>(T1, T2, T3, T4, T5, T6, T7) Create a new 7-tuple, or septuple.
Create<T1, T2, T3, T4, T5, T6, T7, T8>(T1, T2, T3, T4, T5, T6, T7, T8) Create a new 8-tuple, or octuple.


Related Articles

 

About the Author

author
Its me BIPUL who is logically minded creative at heart , a good communicator , a self taught full stack developer. I constantly focuses on my thinking , reading , collecting and creating my work in a order to enhance my skills.

I discover new dimensions for growing bussiness with a proven record in creating database and programming. I have a strong technical skills as well as strong interpersonal skills. Read more...
 

Browse By Category

Popular Articles