Another most useful advantage is it can be used in code blocks. It is called the “Dispose()” method automatically to release the resources and also automatically implements the try catch blocks for you. Here it is called a using statement. So the advantage is that we don’t have to explicitly write a try-catch block and our code looks small.
Example: Defines a scope, outside of which an object or objects will be disposed.
The object can be declared in the using statement, as shown above, or before the using statement as below
Font font = new Font("Times New Roman", 12.0f);
// use font