I have this code snippet:
foreach (var item in allClassesINeedList)
{
var genericMethod = temp.GetType().GetMethod("GenerateDocument").MakeGenericMethod(typeof(item));
genericMethod.Invoke(temp, new object[] { item });
}
It will give me:
"The type or namespace name 'item' could not be found (are you missing a using directive or an assembly reference?)"
My aim is to execute for every object in allClassesINeedList
(its a List<object>
) my generic method GenerateSingleDocument
with every object in that list.
What did I do wrong ?
Aucun commentaire:
Enregistrer un commentaire