Will finally block get executed if the exception had not occurred?

Yes. What is the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?

Showing Answers 1 - 16 of 16 Answers

JamesLex

  • Nov 27th, 2011
 

The purpose of the finally block is to clean up any resources left after the exception occurred. Note that the finally block is always executed, even if no exception was thrown. The catch block is only executed if a managed exception is thrown within the associated try block.
(From the MSDN)

  Was this answer useful?  Yes

Dadan Tiwari

  • Feb 13th, 2012
 

Yes. Finally block will always execute whether execption occur or not.

  Was this answer useful?  Yes

Sivavt

  • Mar 25th, 2012
 

Yes. Finally will be executed even if the exception hasn't occurred.

Catch all statement.

Code
  1. try{}

  2. catch{}

  3.  

  4. Or

  5.  

  6. try{}

  7. catch(Exception e){}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions