C# 4.0 includes a new feature called Tuple. In mathematics, tuple is an ordered list of specific number of values called the components of the tuple. For example, a 3-tuple name may be used as: (First-Name, Middle-Name, Last-Name).
Let's take a look at the following example:
public Tuple<int, int> GetDivAndRemainder(int i, int j)
{
Tuple.Create(i/j, i%j);
}
public void CallMethod()
{
var tuple = GetDivAndRemainder(10,3);
Console.WriteLine("{0} and {1}", tuple.item1, tuple.item2);
}
In the above example, the method can return a tuple which has two integer values. So using tuple, we can return multiple values. So this will help lazy programmers to write less code but do more. One great use of tuple might be returning multiple values from a method.
To get more information on Tuple, visit the following links:
CodeProject