GeekInterview.com
Series: Subject: Topic:
Question: 378 of 460

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?
Asked by: Interview Candidate | Asked on: Sep 15th, 2004
Showing Answers 1 - 6 of 6 Answers
sahu

Answered On : Dec 12th, 2005

View all questions by sahu   View all answers by sahu

Ans:

Yes

Yes  1 User has rated as useful.
  
Login to rate this answer.
srinath1826

Answered On : Aug 4th, 2008

View all answers by srinath1826

Yes, the final block gets executed the order of the execution is:Try block, Catch block and Finally block.

  
Login to rate this answer.
JamesLex

Answered On : Nov 27th, 2011

View all answers by JamesLex

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)

  
Login to rate this answer.

Yes

  
Login to rate this answer.
Dadan Tiwari

Answered On : Feb 13th, 2012

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

  
Login to rate this answer.
Sivavt

Answered On : Mar 25th, 2012

View all answers by Sivavt

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){}

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.