Home > DeveloperSection > Interviews > What is the function of the Try-Catch-Finally block?

Posted on    August-27-2014 11:55 PM

 C# C# 
 1 Answer(s)
  934  View(s)
Rate this:

Sumit Kesarwani

Total Post:782

Posted on    August-27-2014 12:00 AM

The try block encloses those statements that can cause exception and the catch block handles the exception, if it occurs. Catch block contains the statements that have to be executed, when an exception occurs. The finally block always executes, irrespective of the fact whether or not an exception has occurred. The finally block is generally used to perform the cleanup process. If any exception occurs in the try block, the program control directly transfers to its corresponding catch block and later to the finally block. If no exception occurs inside the try block, then the program control transfers directly to the finally block.

Don't want to miss updates? Please click the below button!

Follow MindStick