Using keyword in C#
There are two ways of using the using keyword in C#:
Using keyword as a statement
MSDN says the using keyword
Provides a convenient syntax that ensures the correct use of IDisposable objects.
This is also a way of saying that this is the standard way of releasing unmanaged resources. The following is an example of its usage:
Using keyword as a directive
This is the most common usage of the using keyword. The following example shows how using keyword is used to access types in a namespace. This practice of using the using directives to access types in a namespace allows the developer to avoid fully qualifying the type. This save a lot of time and typing.
Another use of using is to create aliases. An excellent discussion on this topic can be found in this Stackoverflow thread.
View original post 163 mots de plus