---
title: "What is the use of using keyword in C#"  
description: "What is the use of using keyword in C#"  
author: "Niraj Kumar Mishra"  
published: 2017-08-22  
updated: 2020-09-14  
canonical: https://www.mindstick.com/interview/23286/what-is-the-use-of-using-keyword-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# What is the use of using keyword in C#

We can use using keyword in C# program in to Place.\
**Place 1:** Generally when you want to add any namespace in your program then it is useful like: using System; using System.Collections.Generic; using System.Linq; using System.Web; **\** **Place 2:** Second we use using keyword when you want to close ( destroy ) any object connection automatically then it is very useful like :

```
 using (SqlConnection con = new SqlConnection(//connection string){using (SqlCommand cmd = new SqlCommand(storedProcname, con)){try{    con.open();//data reader code}catch{}}}
```

it close the SqlConnection Automatically....

## Answers

### Answer by Niraj Kumar Mishra

We can use using keyword in C# program in to Place.\
**Place 1:** Generally when you want to add any namespace in your program then it is useful like: using System; using System.Collections.Generic; using System.Linq; using System.Web; **\** **Place 2:** Second we use using keyword when you want to close ( destroy ) any object connection automatically then it is very useful like :

```
 using (SqlConnection con = new SqlConnection(//connection string){using (SqlCommand cmd = new SqlCommand(storedProcname, con)){try{    con.open();//data reader code}catch{}}}
```

it close the SqlConnection Automatically....


---

Original Source: https://www.mindstick.com/interview/23286/what-is-the-use-of-using-keyword-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
