I have the following class tree:
public class A
{
public static object GetMe(SomeOtherClass something)
{
return something.Foo();
}
}
public class B:A
{
public static new object GetMe(SomeOtherClass something)
{
return something.Bar();
}
}
public class C:B
{
}
public class SomeOtherClass
{
}
Given SomeOtherClass parameter = new SomeOtherClass()
) this works:
typeof(B).GetMethod("GetMe", new Type[] { typeof(SomeOtherClass) })).Invoke(null, parameter));
But this:
typeof(C).GetMethod("GetMe", new Type[] { typeof(SomeOtherClass) })).Invoke(null, parameter));
throws a NullReferenceException
, while I wish it would call the exact same method than above.
I've tried several binding flags to no avail. Any help?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…