Closing the XmlTextReader

The XmlTextReader should be explicitly closed whenever possible. Explicitly closing it will free up any resources that may be in use while reading the stream. These could be file handles, Web response streams, sockets, or just plain string data. Letting the XmlTextReader go out of scope is not an acceptable way to free up these resources. Besides, explicitly closing the reader is a deterministic way to free up resources. That means there is no reason to guess when resources are available or to attempt to program around resources that are stuck in limbo.

Get Microsoft® .NET Compact Framework Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.