May 2010
Intermediate to advanced
1272 pages
61h 18m
English
Using..End Using StatementAs an alternative to directly invoking Dispose, you can take advantage of the Using..End Using statement. This code block automatically releases and removes from memory the object that it points to, invoking Dispose behind the scenes for you. The following code example shows how you can open a stream for writing a file ensuring that the stream will be released even if you do not explicitly close it:
![]()
Notice how you simply create an instance of the object via the Using keyword. The End Using statement causes Dispose to be invoked on the previously mentioned instance. The advantage of Using..End Using is also that the resource ...
Read now
Unlock full access