Here is source code of the C# Program to Create an Instance of StackTrace and to Get all Frames. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
* C# Program to Create an Instance of StackTrace and to Get all Frames
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)
Here is the output of the C# Program:
Method Names : Main nExecuteAssembly ExecuteAssembly RunUsersAssembly ThreadStart_Context Run ThreadStart
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
If you liked this C# Program, kindly share, recommend or like below!