---
title: "What is the function of the Try-Catch-Finally block?"  
description: "What is the function of the Try-Catch-Finally block?"  
author: "Sumit Kesarwani"  
published: 2014-08-27  
updated: 2020-09-16  
canonical: https://www.mindstick.com/interview/2065/what-is-the-function-of-the-try-catch-finally-block  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# What is the function of the Try-Catch-Finally block?

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.

## Answers

### Answer by Sumit Kesarwani

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.


---

Original Source: https://www.mindstick.com/interview/2065/what-is-the-function-of-the-try-catch-finally-block

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
