public static void Main(string[] args)
{
Action a = () => Console.WriteLine(MethodInfo.GetCurrentMethod().Name);
a();
}
This code will r
If you are looking for getting the name of the function in which the anonymous method resides in you could travel the stack and get the name of the calling method. Do note though, that this would only work as long as your desired method name is one step up in the hierarchy. Maybe there's a way of travelling up until you reach a non-anonymous method.
For more information see: http://www.csharp-examples.net/reflection-calling-method-name/