20
Reply

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

    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(); }

    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;

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

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

    For importin namespace & Closing connection

    For importin namespace & Closing connection

    For importin namespace & Closing connection

    For importin namespace & Closing connection

    For importin namespace & Closing connection

    For importin namespace & Closing connection

    For importin namespace & Closing connection

    For importin namespace & Closing connection

    Using Keyword to used pre-defined classes

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

    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.

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

    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

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

    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

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