Is finally executed in this case? I wrote this code and couldn't decide if finally is really executed in this case or not. I would really like some explanations no matter what the answer is.
foreach(string s in allStrings)
{
try
{
//Error happens here
}
catch(Exception ex)
{
//Handle exception
break;
}
finally
{
//Clean up code
}
}
You've written 90% of the code that you'd need to answer this question for yourself.
Keep writing.
Yes. Finally blocks are always executed when control leaves a corresponding try or catch block. (Unless something super-special happens, like a runtime crash or the thread was aborted.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With