I am wondering why the StackOverflowException is not caught while running the following program.
The program is just terminated due to StackOverflowException, why doesnt it catch the exception before it terminates?
Could anyone please explain? Thanks.
class program
{
private static int val = 0;
static void Main(string[] args)
{
Recursive();
}
static void Recursive()
{
try
{
Console.WriteLine(val);
val++;
Recursive();
}
catch(StackOverflowException e)
{
Console.WriteLine(e.Message);
return;
}
}
}
Why doesnt StackOverflowException get caught here?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Guest UserRank #1,422 · 1.2K reputationPosted Mar 14, 2011, 11:19 AM EDT
http://msdn.microsoft.com/en-us/library/system.stackoverflowexception.aspx