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()