Returning from function through catch block, what happens to finally block?
c#, exception, return-value, try-catch-finally
Solution
It will execute "finally" block after return. "Finally" is used for some practice such as close database connection (always need to be done)
Problem
I've try catch finally block and if some exception occurs I'll return from the catch block, so finally block is still executed, if so, when? Before return or after return? Is this the right practice? ``` try { // do something } catch (Exception) { return false; } finally { if (connection.State == ConnectionState.Open) connection.Close(); } ```