如何从a调用静态方法Type,假设我知道Type变量的值和静态方法的名称?
public class FooClass {
public static FooMethod() {
//do something
}
}
public class BarClass {
public void BarMethod(Type t) {
FooClass.FooMethod() //works fine
if (t is FooClass) {
t.FooMethod(); //should call FooClass.FooMethod(); compile error
}
}
}
Run Code Online (Sandbox Code Playgroud)
因此,给定一个Type t,目标是调用FooMethod()该类Type t.基本上我需要反转typeof()操作员.
c# ×1