Display the call stack method names in C#
using System.Diagnostics; [STAThread] public static void Main() { //obtain call stack StackTrace stackTrace = new StackTrace(); // obtain method calls (frames) StackFrame[] stackFrames = stackTrace.GetFrames(); // display method names foreach (StackFrame stackFrame in stackFrames) { Console.WriteLine(stackFrame.GetMethod().Name); // output method name } }
