C# : use Tuple to list different type.

4/1/2014·1 min read

Have you ever having a case like, wish you can save different type of list. In that case, C#'s Tuple object is able to handler that.

There're not so much case you can List be different type, but it should be some case, you need some time. Which might help your coding easier.

How to use Tuple class

Following is one to use it.

C# -- create and set value for Tuplepublic void Test()
Tuple<intDateTime tuple = Tuple.Create(1000, new DateTime(2011, 10, 1));public int Id { get ; set ;} 
decimal howMuch = tuple.Item1; 
DateTime when = tuple.Item2;