Possible Duplicate:
How can I pass an anonymous type to a method?
Im trying to recognize the type of the anonymous type.
List<int> lst = new List<int> {1, 2, 3, 4, 5};
var myVarType = from item in lst select new {P = item*item, P2 = item + "###"};
foreach (var k in myVarType)
{
Console.WriteLine(k.P + " " + k.P2);
}
Now i want a part of code to be transferred to a function but it screams that he doesnt know the type - which is logical since var is to be known at compile time and he doesnt know the type at compile :
I dont want to use dynamic || Tuples.
and as you know var is not acceptable as a func param type.
But , Ive once read that there is a trick
which lets me transfer to myFunc
the anonymous type
.
I think it was by Jon skeet or Eric lippert.
Help ?
edit
look at my self answer. I found it here What's the return type of an anonymous class