用C#作為參數(shù)的PASS方法我有幾個(gè)方法都有相同的簽名(參數(shù)和返回值),但不同的名稱和方法的內(nèi)部是不同的。我希望將該方法的名稱傳遞給另一個(gè)將調(diào)用傳遞的In方法的方法。public int Method1(string){
... do something return myInt;}public int Method2(string){
... do something different return myInt;}public bool RunTheMethod([Method Name passed in here] myMethodName){
... do stuff int i = myMethodName("My String");
... do more stuff return true;}public bool Test(){
return RunTheMethod(Method1);}這段代碼不起作用,但這正是我所要做的。我不明白的是如何編寫RunTheMethod代碼,因?yàn)槲倚枰x參數(shù)。
- 3 回答
- 0 關(guān)注
- 826 瀏覽
添加回答
舉報(bào)
0/150
提交
取消