Perhaps my eyes are fooling me, but how is it that in .NET 2.0, XmlReader implements Dispose but does not have a Dispose() method? I see it has Dispose(bool), but not a parameterless overload.
Asked
Active
Viewed 913 times
2 Answers
2
It implements it explicitly System.IDisposable.Dispose(). Dispose(boolean) is a normal method that does this ...
protected virtual void Dispose(bool disposing)
{
if (this.ReadState != ReadState.Closed)
{
this.Close();
}
}

JP Alioto
- 44,864
- 6
- 88
- 112
-
Thanks. I knew it was something simple I had just glossed over. – Jul 01 '09 at 02:24
1
... so you need to call it for ex. this way
XmlReader r = XmlReader.Create(s);
((IDisposable)r).Dispose();

Ariel
- 5,752
- 5
- 49
- 59
-
-
...I suppose I shouldn't have used the word "implicit," given the context of the conversation. – Jul 01 '09 at 02:30
-
Am I assuming correctly that calling the .Close() method will serve the same purpose? – ganders May 17 '12 at 12:41