Why in c# can't we wrap anonymous objects in list of objects?
For Example I have seen this Question in StackOverFlow C# Linq, object definition does not contains a property
var anynomousObject = new { Amount = 10, weight = 20 };
List<object> ListOfAnynomous = new List<object> { anynomousObject, anynomousObject };
var productQuery =
from prod in ListOfAnynomous
select new { prod.Amount, prod.weight };
foreach (var v in productQuery)
{
Console.WriteLine(v.Amount);
Console.WriteLine(v.weight);
}
and the answer was that he should wrap the anonymous in list of dynamic but actually I can't understand why in the run time we can't get their values.
from dynamic prod in ...works.