1
我想知道如何使用反射生成多种类型的方法。 实施例:使用反射生成多种方法
class A() {
public void CoreMethod1() {
}
public void CoreMethod2() {
}
// .. 20 such core methods
public void Method1() {
//some initializations
//call to CoreMethod1();
}
public void Method2() {
//some initializations
//call to CoreMethod2();
}
// i need 20 such methods which will call their respective CoreMethods
//Method1(),Method2() are similar except for their call to the core method. i.e Every respective method will call its coremethod. Ex : Method1() -> CoreMethod1(), Method2() -> CoreMethod2()
}
我的问题,我可以生成方法1(),方法2(),方法3()..动态调用各自的核心的方法。有没有更好的方法来完成这件事?