Do I need to Dispose XmlReader if I Dispose its underlying Stream?

The best "rule of thumb" to work by is:

If something implements IDisposable, always wrap it in a using() block to ensure that any unmanaged resources it owns are disposed of correctly.

Relying on the fact that the current implementation of "something" disposes of an underlying resource is dangerous and it won't hurt to wrap everything in a using, just to be on the safe side =)


You're right, you don't have to dispose the reader. But in the code given, it wouldn't hurt either.

I would not put a using block inside LoadDocument() because it is designed so that it 'borrows' it's stream (it does not create it).

But there are arguments to Dispose the XmlReader anyway, just because it's IDisposable. I don't think there is a clear winner here because of the disputable design of the Reader (and Writer) family: They Dispose their baseStreams without clearly being the owner of those streams.