Code try
{
try
{
throw new ApplicationException();
}
finally
{
throw new SystemException();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.GetType().Name);
}
Output SystemException. Reason When ApplicationException is raise, it will goes to within the exception stack, and the finally block also will run and throw system exception, now system exception also goes to within the exception stack.But when we are print within catch, system exception is most recently added, this is will be retrieved first from stack.so SystemException is result for above code. |