I am right that you will need to use () for the outermost thread if you do, for example
MemoryStream mstr = new MemoryStream();
using(StreamWriter w = new StreamWriter(mstr)) {
....
}
How to dispose StreamWriter should also dispose / close the underlying stream, there is no need to do this:
using(MemoryStream mstr = new MemoryStream())
using(StreamWriter w = new StreamWriter(mstr)) {
....
}
(Note that these are just examples of how to remove wrapped threads without looking for alternatives, like just using StringWriter, etc.)
source
share