int i=0;
try{
int j = 10/i;
}
catch(IOException e){}
finally{
Console.WriteLine("In finally");
Console.ReadLine();
}
The finally block does not seem to execute when pressing F5 in VS2008.
I am using this code in Console Application.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Visual Studio debugger halts execution when you get an uncaught exception (in this case a divide by zero exception). In debug mode Visual Studio prefers to break execution and give you a popup box at the source of the error rather than letting the application crash. This is to help you find uncaught errors and fix them. This won’t happen if you detach the debugger.
Try running it in release mode from the console without the debugger attached and you will see your message.