Quick XmlTextReader question

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi All,
if i have the following code:
StringReader stringReader = new StringReader(c_XML);
XmlTextReader xmlReader = new XmlTextReader(stringReader);

If I call 'xmlReader.Close();' I take it the under lying stringReader
close method is called, is this correct?

Thanks,
Nick
 
Nick said:
if i have the following code:
StringReader stringReader = new StringReader(c_XML);
XmlTextReader xmlReader = new XmlTextReader(stringReader);

If I call 'xmlReader.Close();' I take it the under lying stringReader
close method is called, is this correct?

Yes. From the docs:

<quote>
If this reader was constructed using a stream, this method also calls
Close on the underlying stream.
</quote>

It strikes me as unfortunate that XmlTextReader doesn't implement
IDisposable to call Close automatically. I suppose you should probably
have a using block round the stream, in which case it won't matter in
most cases...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top