如果我有這樣的方法:如何獲取方法參數的名稱?
public void MyMethod(int arg1, string arg2)
我將如何去獲得的參數的實際名稱? 我似乎無法找到MethodInfo中的任何東西,它實際上會給我參數的名稱。
我還想寫,看起來像這樣的方法:
public static string GetParamName(MethodInfo method, int index)
所以,如果我把這種方法用:
string name = GetParamName(MyMethod, 0)
它會返回 「ARG1」。這可能嗎?
沒有錯誤檢查只是要求麻煩。 – 2008-12-04 21:19:40