What really happens in a try { return x; } finally { x = null; } statement?
The finally statement is executed, but the return value isn’t affected. The execution order is: Code before return statement is executed Expression in return statement is evaluated finally block is executed Result evaluated in step 2 is returned Here’s a short program to demonstrate: using System; class Test { static string x; static void Main() … Read more