This is a C# Program to create an instance of stacktrace and to get all frames.
This C# Program Creates an Instance of StackTrace and to Get all Frames.
Here It creates an instance of StackTrace (call stack), gets all frames (method calls) and writes the method names.
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 */ 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(); } }
This C# Program is used to create an instance of StackTrace and to get all frames. Here it creates an instance of StackTrace (call stack), gets all frames (method calls) and writes the method names. Using foreach statement, print the frames.
Method Names : Main nExecuteAssembly ExecuteAssembly RunUsersAssembly ThreadStart_Context Run ThreadStart
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
- Check C# Books
- Practice Computer Science MCQs
- Practice MCA MCQs
- Apply for Computer Science Internship
- Apply for C# Internship