using has a second form that is called the using statement.
It has these general forms:
using (obj) {
// use obj
}
using (type obj = initializer) {
// use obj
}
- obj is an object that is being used inside the using block.
- In the first form, the object is declared outside the using statement.
- In the second form, the object is declared within the using statement.
- When the block concludes, the Dispose() method (defined by the System.IDisposable interface) will be called on obj.
- The using statement applies only to objects that implement the System.IDisposable interface.