1
我想獲得一個包含所有可能的重載方法簽名的對象數組,用於類中的方法。例如,如果我們有:如何獲取所有可能的重載方法的簽名?
public class SomeClass {
...
public void SomeMethod() { ... }
public void SomeMethod(int i) { ... }
public void SomeMethod(string s) { ... }
}
我怎樣才能找到所有可能的參數信息?我試過使用:
MethodInfo method = type.GetMethod(methodName);
ParameterInfo[] possibleParameterInfos = method.GetParameters();
foreach (ParameterInfo possibleParameterInfo in possibleParameterInfos)
{
Console.WriteLine(possibleParameterInfo.ParameterType);
}
但我沒有得到我想要的。