Thursday, April 25, 2024 12:19

Posts Tagged ‘using directive’

The Using directive

Sunday, August 5th, 2018

.NET provides a simplified and easier way of working with resources that needs to be disposed (released when we no longer need them) through construct called a Using directive. Here is an example of how we can read a filename (just like in our previous two lessons) and automatically release it when we are done dealing with it, using this keyword:

By enclosing the declaration of our reader variable inside the using instruction, we can use it just as we normally would, but we don’t need to worry about releasing the file when we are done with it.… Read more


Follow the white rabbit