20
Reply

What are the uses of "Using" keyword in C#?

Manas Mohapatra

Manas Mohapatra

Jul 10, 2015
3.5k
1

    We can use Using keyword in following ways:1. Generally we use Using keyword when we add any namespace in our class, code-behind files.. Like: Using System.IO;2. Secondly we can use Using keyword when an object need to destroy automatically. It can be used in ADO.NET, Entity Framework, Web Service call. Here system automatically closes/disposes the object. Like: Using(WCFService cc = new WCFService()) {cc.method(); }

    Manas Mohapatra
    July 10, 2015
    4

    1) using statement is used to call the Dispose method to destroy an object when it's usage is no more. Ex: using (TextWriter w = File.CreateText("log.txt")) { w.WriteLine("This is line one"); } 2) using keyword is used to call namespaces. Ex: using System.IO;

    Mahesh Aelakurthi
    August 14, 2015
    2

    We are using "Using" Keyword in C# .Net for including pre-defined classes in .Net Framework.

    Vijay Kumar
    October 10, 2015
    1

    using statement is used to import the namespaces, and to dispose the objects.

    Jaipal Reddy
    September 11, 2015
    1

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    For importin namespace & Closing connection

    Mukesh Kumar
    September 12, 2017
    0

    Using Keyword to used pre-defined classes

    Kml Surani
    December 21, 2015
    0

    Using key is used for: 1. To include name spaces 2. To close/dispose object.

    Rajesh Singh
    December 05, 2015
    0

    1. It used for including reference of other dll in your project. 2. It is used to dispose object from memory which is inherited from IDisposible interface.

    Dhanik Sahni
    November 17, 2015
    0

    1.For importing name spaces. 2.For providing the scope of object.

    Srikanth Reddy
    November 02, 2015
    0

    I am sure that till now you get to know what are the uses of 'Using'. Here is the link for what happen when we use 'using'. Hope the best.http://www.codeproject.com/Articles/17106/The-using-Keyword-in-C

    Ashok Karale
    October 19, 2015
    0

    "Using" key word suing for importing name spaces and dispose the connections like ADO.NET,WEB SERVICES,ENTITY FRAME WORK etc...

    Vamsi Krishna
    October 12, 2015
    0

    keywords are some special words that are used for special purpose. for example if if is a keyword and it has some special functionality in the program

    Ahtasham Hassan
    September 10, 2015
    0

    1. Used to import namespace. 2. Used to dispose object.

    Sujeet Suman
    September 02, 2015
    0