Reputation: 137
I have a static class and I want to find its private static methods using typeof(MyStaticClass).GetMethods() but it always shows me the public methods only.
How can I achieve this?
Upvotes: 2
Views: 1518
Reputation: 1502935
Use the overload of GetMethods
that includes a BindingFlags
parameter:
var methods = typeof(MyStaticClass)
.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
(I haven't included BindingFlags.Instance
as you've explicitly said it's a static class; to find all methods in any class, include that as well.)
Upvotes: 4