I have a class, which has a protected nested class, and a protected readonly field of the nested class' type. My framework calls
o.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic);
on an instance of the type, I can see the field from debugger, but the call doesn't return it. Why?
You also need to include BindingFlags.Instance
Instance - Specifies that instance members are to be included in the search.
from
BindingFlags Enumeration (System.Reflection)
You should also specify BindingFlags.Instance
if it's a non-static field.
If it's a static field, add BindingFlags.Static
and BindingFlags.FlattenHierarchy
.
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