C# Tuples

In the previous sections, you have learned about the arrays. The arrays can only contain the same type of objects. Like an integer array can only store integer objects, whereas a string array can store only string literals.

Sometimes we have required storing different kind of object into a single variable. In such situations, tuples are a good choice.

The Tuple<T> is basically a class which was introduced with .Net Framework 4.0. Following is the Syntax of creating a tuple.


Tuple<datatype, datatype> VariableName = new Tuple<datatype, datatype>(value1, value2);