J
Jesee
I am reading Jeffrey Richter's book "Applied Microsoft .NET Framework
programming",i came across "Exception handing". Page 405 says
"If the stack overflow occurs within the CLR itself,your application code
won't be able to catch the StackOverflowException exception and none of your
finally blocks will excute.",I don't understand it.
Following C# statement:
class App
{
static void Main()
{
try
{
Console.WriteLine("This process will throw a StackOverflowException");
ThrowStack();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("Finally block execute");
Console.ReadLine();
}
}
static void ThrowStack()
{
try
{
throw new StackOverflowException("StackOverflowException is be throw by
user");
}
catch (StackOverflowException ex)
{
throw ex;
}
}
}
output:
This process will throw a StackOverflowException
StackOverflowException is be throw by user
Finally block execute
It seems catch block catch this exception and finally black execute,why?
Thanks for your help
programming",i came across "Exception handing". Page 405 says
"If the stack overflow occurs within the CLR itself,your application code
won't be able to catch the StackOverflowException exception and none of your
finally blocks will excute.",I don't understand it.
Following C# statement:
class App
{
static void Main()
{
try
{
Console.WriteLine("This process will throw a StackOverflowException");
ThrowStack();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("Finally block execute");
Console.ReadLine();
}
}
static void ThrowStack()
{
try
{
throw new StackOverflowException("StackOverflowException is be throw by
user");
}
catch (StackOverflowException ex)
{
throw ex;
}
}
}
output:
This process will throw a StackOverflowException
StackOverflowException is be throw by user
Finally block execute
It seems catch block catch this exception and finally black execute,why?
Thanks for your help