Monday, 27 August 2012

Programming World: ASP.NET Interview Question

Programming World: ASP.NET Interview Question: ASP.NET With C Sharp (Index) ASP.NET Interview Questions 1. When using an implicitly typed array, which of the fo...

Programming World: Copy records from one table to another in SQL

Programming World: Copy records from one table to another in SQL: SQL Interview Questions (Index) Copy records from one table to another in SQL Many times the following questions are asked regarding...

Thursday, 9 August 2012

System.Diagnostics.StackTrace


StackTrace

The .Net frameworks provides the System.Diagnostics.StackTrace class which allows you to get a stack trace at runtime. It is handy for diagnostic purposes. The StackTrace class has following features:

  • It represents the actual stack running.
  • It only shows managed frames and does not show any native frames.
  • The stack trace class can get method names and even IL offsets without symbols

Example
void PrintStackTrace()
{
StackTrace st = new StackTrace(true); // true means get line numbers.
foreach(StackFrame f in st.GetFrames())
{
Console.Write(f);
}