[C#] Using Reflection to Find a Function Name

I have a test script which will run and log errors found into a file in isolated storage. I wanted to be able to also log the name of the function that was being tested, and after a quick search I see that this can easily be found using Reflection.

System.Reflection.MethodBase thisFunction = System.Reflection.MethodBase.GetCurrentMethod();

string functionName = thisFunction.Name;


Tags:
This entry was posted on Tuesday, May 26th, 2009 at 1:14 pm and is filed under c#. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Your comment