Guest User
What is the use of using statement in C#
By Guest User in C# on Aug 01 2014
  • Abrar Ahmad Ansari
    Mar, 2015 10

    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.

    • 5
  • Joe Wilson
    Dec, 2015 23

    using statement to release all the resources automatically.

    • 1
  • Pankaj  Kumar Choudhary
    Mar, 2015 27

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

    • 1
  • Devender Khowal
    Jan, 2015 20

    For import the Namespace for Close the Connection to database

    • 1
  • Abhishek Yadav
    Sep, 2014 6

    We use using statement to release all the resources automatically.

    • 1
  • Raghav Mehra
    Aug, 2014 26

    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 }

    • 1
  • Sanjeev Kumar
    Aug, 2014 17

    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

    • 1
  • Amar Bhagat
    Mar, 2018 27

    Yes

    • 0
  • Amar Bhagat
    Mar, 2018 27

    using statement calls "Dispose" method internally when exception occurred in any method.

    • 0
  • Asfend Yar
    Mar, 2017 9

    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.

    • 0
  • cool sign
    Aug, 2015 10

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

    • 0
  • Sreeni Dony
    Jul, 2015 22

    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.

    • 0
  • Sreekanth Reddy
    Jul, 2015 11

    For importing namespaces.

    • 0
  • Safayat Zisan
    Apr, 2015 17

    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

    • 0
  • PRABHAKAR PANDEY
    Jan, 2015 29

    It is used to define the statement

    • 0
  • Md. Raskinur Rashid
    Jan, 2015 20

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

    • 0
  • Dhanik Sahni
    Oct, 2014 9

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

    • 0
  • Munesh Sharma
    Oct, 2014 9

    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

    • 0
  • Sunil Gaded
    Aug, 2014 28

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

    • 0
  • Ankur Jain
    Aug, 2014 18

    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.

    • 0
  • manikumar maddu
    Aug, 2014 5

    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.

    • 0
  • Guest User
    Aug, 2014 1

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

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS