How the finally block is processed if the construction is in progress
try {
try {}
catch {}
finally {}
}
catch {}
finally {}
Will this and that block work, or will it?
Answer 1, authority 100%
Both finally
should work, because block finally
Always works (see documentation ) if the exception is caught. If not caught, then there are no execution guarantees.
Answer 2, authority 60%
static void Main (string [] args)
{
try {
try {
throw new Exception ();
}
catch {
Console.WriteLine ("Inner catch");
}
finally {
Console.WriteLine ("Inner finally");
}
}
catch {
Console.WriteLine ("Outer catch");
}
finally {
Console.WriteLine ("Outer finally");
}
}
Result:
Inner catch
Inner finally
Outer finally