C# Programming - Exception Handling - Discussion

Discussion Forum : Exception Handling - General Questions (Q.No. 15)
15.
All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
1 comments Page 1 of 1.

Mike said:   1 decade ago
This is wrong, the 2nd WriteLine below will not run, and it's in the finally block! (the wording of the question is too vague).

It should be "Code inside a finally block is always called..."
not "All code inside ....."

try
{
throw new Exception("first exception");
}
finally
{
Console.WriteLine("first message");
throw new Exception("second exception");
Console.WriteLine("second message");
}

Post your comments here:

Your comments will be displayed after verification.