How do I call a static method from a Type
, assuming I know the value of the Type
variable and the name of the static method?
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
}
}
}
So, given a Type t
, the objective is to call FooMethod()
on the class that is of Type t
. Basically I need to reverse the typeof()
operator.