I have some sample code looking like this:
var items = new List<object>();
var testObjectOne = new
{
Valueone = "test1",
ValueTwo = "test2",
ValueThree = "test3"
};
var testObjectTwo = new
{
Valueone = "test1",
ValueTwo = "test2",
ValueThree = "test3"
};
items.Add(testObjectOne);
items.Add(testObjectTwo);
foreach (var obj in items)
{
var val = obj.Valueone;
}
But I can't access Valueone and get the error: object' does not contain a definition for 'Valueone' and no extension method 'Valueone' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Question: How can i iterate through this list and access ValueOne for example? Any help or input is highly appreciated, thanks