---
title: "Why to use “finally” block in C#?"  
description: "Why to use “finally” block in C#?"  
author: "Anonymous User"  
published: 2018-05-28  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/23414/why-to-use-finally-block-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Why to use “finally” block in C#?

Finally block will be executed irrespective of exception, while executing the code in try block when exception is occurred then control is returned to catch block then in the last “finally” block will be executed the closing connection to database / releasing the file handlers can be kept in “finally” block.

## Answers

### Answer by Anonymous User

Finally block will be executed irrespective of exception, while executing the code in try block when exception is occurred then control is returned to catch block then in the last “finally” block will be executed the closing connection to database / releasing the file handlers can be kept in “finally” block.


---

Original Source: https://www.mindstick.com/interview/23414/why-to-use-finally-block-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
