20
Reply

What is the use of using statement in C#

Sumit Jolly

Sumit Jolly

Aug 01, 2014
20.5k
0

    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
    March 10, 2015
    4

    using statement to release all the resources automatically.

    Joe Wilson
    December 23, 2015
    1

    using statement is use to implement all classes and objects ,method which are define in a namespace

    For import the Namespace for Close the Connection to database

    Devender Khowal
    January 20, 2015
    1

    We use using statement to release all the resources automatically.

    Abhishek Yadav
    September 06, 2014
    1

    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
    March 09, 2017
    0

    Auto dispose the objects ,when the execution of block completed. and Importing Namespaces

    cool sign
    August 10, 2015
    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
    July 22, 2015
    0

    For importing namespaces.

    Srikanth Reddy
    July 11, 2015
    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
    April 17, 2015
    0

    It is used to define the statement

    PRABHAKAR PANDEY
    January 29, 2015
    0

    It's a syntax to include system file ot import namespace

    Md. Raskinur Rashid
    January 20, 2015
    0

    1. Referencing Namespace 2. Deallocting objects which has implemented IDisposable Interface

    Dhanik Sahni
    October 09, 2014
    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
    October 09, 2014
    0

    if we r use the using then it automatically release the objects from the memory

    Sunil Gaded
    August 28, 2014
    0

    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
    August 26, 2014
    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
    August 18, 2014
    0

    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
    August 17, 2014
    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
    August 05, 2014
    0

    The using block is used to obtain a resource and use it and then automatically dispose of when the execution of block completed.

    Sumit Jolly
    August 01, 2014
    0