C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
22
Reply
What is the use of using statement in C#
Guest User
11y
27.8k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
there is 2 use using statement. 1:- Importing namespace example:using System; 2:- dispose the object using(SqlConnection oConnection=new SqlConnection()) { oConnection.Open(); } if you won't close the connection it will close the connection automatically once SqlConnection has been executed completing.
Abrar Ahmad Ansari
10y
5
using statement to release all the resources automatically.
Joe Wilson
9y
1
using statement is use to implement all classes and objects ,method which are define in a namespace
Pankaj Kumar Choudhary
10y
1
For import the Namespace for Close the Connection to database
Devender Khowal
10y
1
We use using statement to release all the resources automatically.
Abhishek Yadav
11y
1
The using statement is mostly used when you need to one or more resources in a segment. The using statement obtains one or various resources, executes them and then releases the objects or resources. It is widely used in database connectivity through C#.Using (SqlConnection conn = new SqlConnection()){}When we use above block, internally the code is generated like this SqlConnection conn = new SqlConnection() try{}finally{// calls the dispose method of the conn object }
Raghav Mehra
11y
1
The using statement automatically calls the Dispose() method on the object when leaving the scope of the using statement. using statement is more elegant way of disposing object than manual dispose
Sanjeev Kumar
11y
1
Yes
Amar Bhagat
7y
0
using statement calls "Dispose" method internally when exception occurred in any method.
Amar Bhagat
7y
0
The reason for the "using" statement is to ensure that the object is disposed as soon as it goes out of scope, and it doesn't require explicit code to ensure that this happens.
Asfend Yar
8y
0
Auto dispose the objects ,when the execution of block completed. and Importing Namespaces
cool sign
10y
0
A class which inherits from IDisposable interface and also defines Dispose method for releasing resources from memory.The same class can be used in "Using" statement.
Sreeni Dony
10y
0
For importing namespaces.
Sreekanth Reddy
10y
0
using statement is used to import the library. In C language, #include
is such a header file which imports the library and under the library various function works. using statement is the same thing. example: using system.data.sqlclient; this imports library of some ado.net methods
Safayat Zisan
10y
0
It is used to define the statement
PRABHAKAR PANDEY
10y
0
It's a syntax to include system file ot import namespace
Md. Raskinur Rashid
10y
0
1. Referencing Namespace 2. Deallocting objects which has implemented IDisposable Interface
Dhanik Sahni
11y
0
If a class implements IDisposable then it will create some unmanaged resources which need to be 'disposed' of when you are finished using them.http://stackoverflow.com/questions/75401/uses-of-using-in-c-sharp
Munesh Sharma
11y
0
if we r use the using then it automatically release the objects from the memory
Sunil Gaded
11y
0
When you are using an object that encapsulates any resource, you have to make sure that when you are done with the object, the object's Dispose method is called. The using statement simplifies the code that you have to write to create and then finally clean up the object.
Ankur Jain
11y
0
The using statement simplifies the code that you have to write to create and then finally clean up the object. The using statement obtains the resource specified, executes the statements and finally calls the Dispose method of the object to clean up the object.
manikumar maddu
11y
0
The using block is used to obtain a resource and use it and then automatically dispose of when the execution of block completed.
Guest User
11y
0
What is serialization?
Is string mutable or immutable?
Message