Importance of Using keyword in C#

  • Using keyword plays a vital role in improving the performance of Garbage Collection.

  • using for namespace means that the types from the imported namespace will be referenced in code

Disposing Resources

The using statement can be used to reference a variable or the result from a method, and at the end of the scope defined by the using statement, the Dispose method gets invoked
 
 
 
 
 
 
 
 
 
 
 
 
 
Behind the seen it works like-
 

Using Directive

Generally Using key word we are using to add namespaces in the class. Using that all the classes, interfaces and abstract classes and their methods and properties available in the current class. we can declare namespace as given below. 

I hope it gives you better understanding of using keyword in C#.

Keep Learning

 

Leave a Reply