Possible Duplicate:
What’s the return type of an anonymous class
I’m creating an anonymous type with query like the following:
Caller code:
var query= from p in _db.ExecuteDataSet(SQL).Tables[0].AsEnumerable()
select new {
ProductCode = p.Field<string>("PRODUCT_CODE"),
ProductName = p.Field<string>("PRODUCT_NAME")
};
foreach(var product in query)
{
WriteProduct(product);
}
Method is like:
void WriteProduct(object prod)
{
// access the product
}
I fail to get the correct Parameter Type for the WriteProduct method. Please help me.
Yes you can.
But as a small, minor detail, DON’T!
Anonymous types are anonymous for a reason, they aren’t first class entities in your code, they’re more of a convenience. If a type is that important, define it as such.