![](/img/trans.png)
[英]How to get the MethodInfo of a function of a class, without string comparison
[英]How to get a function's MethodInfo from within the function?
假設有一個 function GetEmployees
:
public static List<Employee> GetEmployees(Dictionary<int, Department> depts, bool isFullTime)
{
// How do I get the MethodInfo of this "GetEmployees" function by writing code here?
}
我需要在這個 function 中獲取MethodInfo的原因是我需要知道
謝謝!
我希望你想要這個:
MethodInfo myMethod = MethodInfo.GetCurrentMethod();
你可以像這樣得到反射的參數:
ParameterInfo[] parameters = myMethod.GetParameters();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.