I am trying to get the values from objects inside a list which is part of a main object.
I have the main object which contains various properties which can be collec
See if something like this helps you in the right direction: I got the same error a while back and this code snipped solved my issue.
PropertyInfo[] properties = MyClass.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
if (property.Name == "MyProperty")
{
object value = results.GetType().GetProperty(property.Name).GetValue(MyClass, null);
if (value != null)
{
//assign the value
}
}
}