c# - GetField const in type's base class -
After
I can use the reflection in Net 4 to get the field information from a derived class to a base class Are you
For example,
class guardian {public const bool ParentField = true; } Category: Children: Parents {Public Controlled Bull Childfield = true; }
Using those sections:
Console.WriteLine (.P.GetType () GetField ("ParentField")); Console.WriteLine (.GetType () GetField ("ChildField")); Console.WriteLine (.GetType () GetField ("ParentField"));
The way I expect the third line, it does not work. GetField
provides zero when obtaining a region from the base type. I have tried to overload GetField
with all the different BindingsFlags
values I can think of, but it always gives nullity.
Edit
I should have been clear that this
c.GetType () GetField ("ParentField", BindingFlags.FlattenHierarchy)
also gives nullity.
"itemprop =" text ">
inherited constants you get to be a little more specific.
c.GetType () GetField (| | BindingFlags.Static BindingFlags.FlattenHierarchy "ParentField", BindingFlags.Public): with your binding flag >
Comments
Post a Comment