Having an issue with getting a static method from a parent object. Examine the following code:
var objType = typeof(myClass); // myClass is a ChildClass object
var methods = objType.GetMethods(BindingFlags.Static | BindingFlags.FlattenHierarchy);
Parent Class:
public class ParentClass {
public static T GrabStuff<T>(string values) {
GrabStuff<T>(values, false);
}
// ---- Updated
public static T GrabStuff<T>(string values, bool isSomething) {
// TODO: Do Stuff
}
// ---- Updated
}
Child Class:
public class ChildClass : ParentClass {
}
Methods is returning and array of 0 objects.
Am I doing something wrong here to pull a list of static methods?
You didn’t specify
BindingFlags.Public:With this change the
MethodInfo‘s forGrabStuff,EqualsandReferenceEqualsare returned.