Skip to content

Instantly share code, notes, and snippets.

@andylshort
Created March 24, 2018 10:59
Show Gist options
  • Save andylshort/cdc5ec88c2e2b9e8bd6ab947a17411ce to your computer and use it in GitHub Desktop.
Save andylshort/cdc5ec88c2e2b9e8bd6ab947a17411ce to your computer and use it in GitHub Desktop.
Gets the name of the currently executing method
// Requires:
// using System.Diagnostics;
// using System.Runtime.CompilerServices;
[MethodImpl(MethodImplOptions.NoInlining)]
public static string GetCurrentMethod()
{
StackTrace st = new StackTrace();
StackFrame sf = st.GetFrame(1);
return sf.GetMethod().Name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment