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.
- Get Free Certificate of Merit in C# Programming
- Participate in C# Programming Certification Contest
- Become a Top Ranker in C# Programming
- Take C# Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for C# Internship
- Buy MCA Books
- Practice MCA MCQs
- Apply for Computer Science Internship
- Buy C# Books