What are the 2 use of using statement in C#?
Gaurav Mishra
There are more than 2 uses. 1. To import the namespace e.g. using System; 2. To create an alias e.g. using connection= System.Data.Common.DbConnection; 3. To wrap the disposing of an IDisposable in a Try/ Finally block to ensure Dispose is called on the IDisposable IDisposable d = new DisposableObject(); try { .... } finally { d.Dispose(); }
1: To import the namespace