I am currently learning how to do reflection and I have been succesful with regards to getting the propeties and values of a stringly typed class. However, when I try with a dynamic
object, I get an exception:
System.Reflection.TargetParameterCountException: Parameter count mismatch.
I've tried some of the solutions (e.g. object foo = dynamic obj
then using obj
) here but none seem to work because they don't quite reflect my problem.
Here is my code:
dynamic evtPc1 = JsonConvert.DeserializeObject(json);
PropertyInfo[] properties = evtPc1.GetType().GetProperties();
for (int i = 0; i < properties.Length; i++)
{
Console.WriteLine($"Property: {properties[i].GetValue(evtPc1)}");
}
Aucun commentaire:
Enregistrer un commentaire