Ans:
The using statement allows the programmer to specify when objects that use resources should release them. The object provided to the using statement must implement the IDisposable interface. This interface provides the Dispose method, which should release the object's resources.
The using statement tells .NET to release the object specified in the using block once it is no longer needed.
The using statement allows the programmer to specify when objects that use resources should release them. The object provided to the using statement must implement the IDisposable interface. This interface provides the Dispose method, which should release the object's resources.
The using statement tells .NET to release the object specified in the using block once it is no longer needed.
using (B a = new B())
{
   DoSomethingWith(a);
}
is equivalent to
B a = new B();
try
{
  DoSomethingWith(a);
}
finally
{
   ((IDisposable)a).Dispose();
} 
No comments:
Post a Comment