---
title: "Difference Between Close() and Dispose() Method."  
description: "The basic difference between Close() and Dispose() is, when a Close() method is called, connection will be temporarily closed and can be opened once a"  
author: "Pushpendra Singh"  
published: 2010-12-18  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/75/difference-between-close-and-dispose-method  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Difference Between Close() and Dispose() Method.

The [basic difference](https://www.mindstick.com/interview/2438/what-is-the-basic-difference-between-string-and-stringbuffer-object) between [Close](https://yourviews.mindstick.com/story/1687/rubbing-hands-close-up-benefits)() and Dispose() is, when a Close() [method](https://www.mindstick.com/forum/166/webservice-method) is called, [connection](https://www.mindstick.com/articles/13012/what-makes-ethernet-connection-better-than-wifi) will be temporarily closed and can be opened once again. Where as Dispose() method permanently close and removes connection object from [memory](https://www.mindstick.com/blog/300050/what-causes-sudden-memory-loss) and the [resource](https://www.mindstick.com/blog/43433/top-best-resources-for-women-about-beauty-and-health) no longer [exists](https://www.mindstick.com/forum/158947/how-do-you-use-the-exists-operator-to-check-for-the-existence-of-records-in-a-subquery) for any further processing.\

##### Example:

```
try{string constring = "Server=(local);Database=my; User Id=sa; Password=sa";SqlConnection sqlcon = new SqlConnection(constring); sqlcon.Open();   // here connection is open
// some code here which will be execute}catch{     // code  will be execute when  error occurred in try block}finally{ sqlcon.Close();                // close the connectionsqlcon.Dispose();         // desroy the  connection object}
```

---

Original Source: https://www.mindstick.com/blog/75/difference-between-close-and-dispose-method

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
