Code:
using System.Diagnostics;
using System;
class program
{
public static void Main()
{
StackTrace stackTrace = new StackTrace();
StackFrame[] stackFrames = stackTrace.GetFrames();
// write call stack method names
Console.WriteLine("Method Names : ");
foreach (StackFrame stackFrame in stackFrames)
{
Console.WriteLine(stackFrame.GetMethod().Name);
}
Console.Read();
}
}
Output:
Method Names :
Main
nExecuteAssembly
ExecuteAssembly
RunUsersAssembly
ThreadStart_Context
Run
ThreadStart
More C# Programs: