// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Diagnostics; using System.Reflection; class MainClass { public static void Main(string[] args) { Sub1(); Sub3(); } public static void Sub1() { Sub2(); } public static void Sub2() { Test(); } public static void Sub3() { Test(); } public static void Test() { StackTrace trace = new StackTrace(true); for(int i = 0; i < trace.FrameCount; i++) { StackFrame frame = trace.GetFrame(i); MethodBase method = frame.GetMethod(); Console.WriteLine(method.DeclaringType + " " + method.Name); } } }