Exception Handling in C#
Hello guys, sorry to disturb you all; consider the following code:
I have a question. I know that try-catch blocks are used to handle exceptions and the finally block is used to "release" any resource after the catch block has been executed. The finally block is always executed irrespective if their is an error or not.
My question is, in the above code, notice the inner try-finally statement doesn't have a catch block. So if their is an error in this try block, what happens? We noticed that their is no catch block in the inner try block, so we start looking in the outer try block? What about the finally block, we don't execute it until we finish scheming in the outer try-block? Does this mean that any catch block will always run before any finally block?
I have a question. I know that try-catch blocks are used to handle exceptions and the finally block is used to "release" any resource after the catch block has been executed. The finally block is always executed irrespective if their is an error or not.
My question is, in the above code, notice the inner try-finally statement doesn't have a catch block. So if their is an error in this try block, what happens? We noticed that their is no catch block in the inner try block, so we start looking in the outer try block? What about the finally block, we don't execute it until we finish scheming in the outer try-block? Does this mean that any catch block will always run before any finally block?
