user788454
user788454

Reputation:

How to get a function's MethodInfo from within the function?

Suppose there is a 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?
}

The reason I need to get the MethodInfo inside this function is that I need to know

Thanks!

Upvotes: 0

Views: 99

Answers (1)

ProgrammingLlama
ProgrammingLlama

Reputation: 38737

I expect you want this:

MethodInfo myMethod = MethodInfo.GetCurrentMethod();

And you can get the reflected parameters like so:

ParameterInfo[] parameters = myMethod.GetParameters();

Upvotes: 1

Related Questions