Use of StackTrace feature of System.Exception

This feature used to call a stack which records where the exception was thrown from.This will useful at the time of debug build.
The following is the code to explain the "StackTrace" feature.


using System;
class CApp
{
public static void Main()
{
try
{
SomeStaticFunction();
}
catch( Exception e )
{
Console.WriteLine( "System.Exception stack trace = \n{0}", e.StackTrace );
}
}
static void SomeStaticFunction()
{
throw new Exception( "SomeStaticFunction() has some error" );
}
}



Following is the output of the code

System.Exception stack trace =
at CApp.SomeStaticFunction()
at CApp.Main()


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: