I have a list of type object as such
List<object> _list;
I initialize this list in a method and add a few items with properties
void CreateList()
{
_list= new List<object>();
_list.Add(new {Prop1 = 45, Prop2 = "foo", Prop3 = 4.5});
_list.Add(new {Prop1 = 14, Prop2 = "bar", Prop3 = 3.1});
}
However i now have a list of type object and i don't know it's type or the type of the elements.
I want to select a few elements based on their properties from the list using LINQ e.g. FindAll(). How do i go about this? Would it be better to create a POCO class?
dynamicbut strongly typed tends to be better than duck typingobject? You could've usedArrayList. The whole point ofGenericsit to use strongly typed object.List, instead of the most generalList<object>.