Hi
It is good practice to close all the streams after using them. However,
MemoryStream is little bit different. Closing/Disposing this stream doesn't
do much resourcewise. It just marks the stream as closed so no more
reading/writing to the stream are possible. Methods like ToArray() and
GetBuffer() still works, which means that the data is still in the memory.
The Dispose simply calls Close so it doesn't make much of a difference.
Depending on the type of the variable that holds the reference to the stream
(whether it is a local variable or class field), the level of memory
consumptions and the structure of the code that uses this variable it make
become more important to set the variable to *null* than to close/dispose
the stream.
But anyways it is always a good programming practice to close/dispose all
the streams when finish working with them.
--
Stoitcho Goutsev (100) [C# MVP]
"BravesCharm" <ma*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
You should not have to set the variable to null. The only thing you
should need to do is call close/dispose. However, it's always a good
idea to set the variable to null so you know not to use it anymore.