私は次のクラスツリーを持っています:
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
{
}
与えられSomeOtherClass parameter = new SomeOtherClass()
た ) これは動作します:
typeof(B).GetMethod("GetMe", new Type[] { typeof(SomeOtherClass) })).Invoke(null, parameter));
でもこれは:
typeof(C).GetMethod("GetMe", new Type[] { typeof(SomeOtherClass) })).Invoke(null, parameter));
をスローしNullReferenceException
ますが、上記とまったく同じメソッドを呼び出すことを望みます。
いくつかのバインディング フラグを試してみましたが、役に立ちませんでした。何か助けはありますか?