Search code examples
.net-2.0idisposablexmlreader

XmlReader and IDisposable


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.


Solution

  • 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();
        }
    }