Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Last active February 11, 2019 11:25
Show Gist options
  • Save csharpforevermore/c508d0899af8d6440ddca4dc3e3d20c1 to your computer and use it in GitHub Desktop.
Save csharpforevermore/c508d0899af8d6440ddca4dc3e3d20c1 to your computer and use it in GitHub Desktop.
Get calling method name in any C# class.
string name = new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().Name;
Console.WriteLine(name);
@csharpforevermore
Copy link
Author

Modified version of code from Stackoverflow solution here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment