exoteric said:
*snip*
Well, if you look at anonymous methods and captured variables etc, the compiler already creates anonymous classes in that case as you mention. We don't really care too much about the signature of these classes, since they are mostly hidden from us (although
you can certainly see them in the debugger). In addition, when you use IEnumerable and yield return, the compiler infers the type from the return value. So if you combine those two concepts, you can basically have tuples with named items, right?
So in my example, the type of "result", would be something like "<Tuple>a__1" or whatever, but it would contain the public members with the correct names and types. Edit: And this is also what you would see if you used reflection to query the enclosing class's
properties.
BTW, in my example then it should really be returned like this:
public ITuple Result
{
get { return (Count = runCount, Min = runMin, Max = runMax, Avg = runAvg); }
}
So just like you use IEnumerable when using yield return, you use ITuple, and the return type determines its true signature.