.Net 3.5 doesn\'t support tuples. Too bad, But not sure whether the future version of .net will support tuples or not?
#region tuples
public class Tuple
{
public Tuple(T first)
{
First = first;
}
public T First { get; set; }
}
public class Tuple : Tuple
{
public Tuple(T first, T2 second)
: base(first)
{
Second = second;
}
public T2 Second { get; set; }
}
public class Tuple : Tuple
{
public Tuple(T first, T2 second, T3 third)
: base(first, second)
{
Third = third;
}
public T3 Third { get; set; }
}
public class Tuple : Tuple
{
public Tuple(T first, T2 second, T3 third, T4 fourth)
: base(first, second, third)
{
Fourth = fourth;
}
public T4 Fourth { get; set; }
}
#endregion
And to make declarations prettier:
public static class Tuple
{
//Allows Tuple.New(1, "2") instead of new Tuple(1, "2")
public static Tuple New(T1 t1, T2 t2)
{
return new Tuple(t1, t2);
}
//etc...
}