What is the difference between anonymous type and tuple?
Just a little update to this answer since C# 7 is out in the wild. Tuples have super powers now and can sometimes replace anonymous types and classes. Take for example this method that accepts and returns tuples with named properties.
void Main()
{
var result = Whatever((123, true));
Debug.Assert(result.Something == 123);
Debug.Assert(result.Another == "True");
}
(int Something, string Another) Whatever((int Neat, bool Cool) data)
{
return (data.Neat, data.Cool.ToString());
}
That's cool.