My base class has a public static method, but when I call typeof(TDerived).GetMethods(BindingFlags.Public |BindingFlags.Static
) my method doesn't get returned. (TDerived of course inherits in some way from my base class). I don't have a reference to my base class at the place of this query.
What am I doing wrong?
Use the BindingFlags.FlattenHierarchy
flag:
typeof(TDerived).GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
It is a documented behavior in the Remarks section for Type.GetMethods(BindingFlags)
method.
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