Saturday, 2 December 2017

C# Program to Create an Instance of StackTrace and to Get all Frames


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:

















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...