Showing posts with label how to declare a tuple. Show all posts
Showing posts with label how to declare a tuple. Show all posts

Wednesday, January 18, 2017

What is tuple and how to declare it?



A tuple is s new data type introduced in .Net Framework 4.0. It is used when we want to store multiple values having different data type and without having a class to store the value, in this situation the tuple is best option. In other words a Tuple is a container that contains similar or different data type (7 items) and 1 Tuple.

Declaration of Tuple

The declaration of the Tuple is similar to dictionary <tkey, tvalue>
Tuple<t1>
Tuple<t1, t2, t3>
Tuple<t1, t2, t3, t4>
Tuple<t1, t2, t3, t4, t5>
Tuple<t1, t2, t3, t4, t5, t6>
Tuple<t1, t2, t3, t4, t5, t6, t7>
Tuple<t1, t2, t3, t4, t5, t6, t7, tRest>
T is any data type and tRest a tuple type.