Thursday, December 19, 2013

Why use Tuple in C#?

1. To pass or return a group of values in single parameter
2. To create a temp record for a set of data without making a new class for it.

var population = Tuple.Create("New York", 7891957, 7781984, 7894862, 7071639, 7322564, 8008278);
Console.WriteLine("Population of {0} in 2000: {1:N0}",
                  population.Item1, population.Item7);
References:
http://msdn.microsoft.com/en-us/library/system.tuple(v=vs.110).aspx
http://stackoverflow.com/questions/3089706/what-requirement-was-the-tuple-designed-to-solve


No comments:

Post a Comment