Simplified Disposal and Compressed Streams
Learn about the “using” statement for automatic resource management and how to compress XML data using GZip and Brotli algorithms.
We'll cover the following...
We'll cover the following...
We can simplify the code that needs to check for a null object and then call its Dispose method by using the using statement. Generally, we would recommend using using rather than manually calling Dispose is recommended unless we need greater control.
The using keyword
Confusingly, there are two uses for the using keyword:
Importing a namespace.
Generating a
finallystatement that callsDisposeon an object that implementsIDisposable.
The compiler ...