d.GetType().GetProperty("value2").GetValue(d, null);
this returns the value of the value2 property inside d.
I want the value of the property inside value2 i.e d.value2.value3.
How should i achieve this?
object e = d.GetType().GetProperty("value2").GetValue(d, null);
object f = e.GetType().GetProperty("value3").GetValue(e, null);
In C# 4, simply use the dynamic keyword to allow run time evaluation of your properties:
((dynamic) d).value2.value3;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With