Aufrufen einer statischen Methode mit einem Typ
Wie rufe ich eine statische Methode von einem @ auType
, vorausgesetzt ich kenne den Wert desType
Variable und der Name der statischen Methode?
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, gegeben einType t
, das Ziel ist es, @ aufzurufFooMethod()
auf der Klasse, die von @ iType t
. Grundsätzlich muss ich das @ umkehrtypeof()
Operator