I received an object fi.. and it is a field of someone anonymous object.
I want to enlist each element of the object fi if it belongs to Generic class List
if(fi.FieldType.IsGenericType && fi.FieldType.GetGenericTypeDefinition() == typeof(List<>))
{
foreach (object element in (XXX) k.Value)
{
}
}
Well with that particular object I know it is List, so I can cast (List).
My question is: what should I cast to, to do not care about what Type of the list element?
I tried List<>, List .. it says I have to set the element Type to get cast succeeded.
Help.. pls.
Aucun commentaire:
Enregistrer un commentaire