What is using keyword in C#?
Mohan Gupta
using keyword is used Remove unused memory form the objectUsing(SqlConnection objConn=new SqlConnection()) { }
There are two usage of "using" keyword 1. to import namespaces e.g using System;using System.IO; 2. to handle unmanaged resourcesAn object inside or outside the .NET Framework, which uses external code (For example: file handles, streams, DB connections). The Garbage Collector can't handle unmanaged resources, so we need to release them manually. e.g using (Stream input = File.OpenRead(filename)) {... } This can only be used with types that implement IDisposable.