Although there are quite a lot of Q&As regarding IDisposable
to be found on SO, I haven't found an answer to this yet:
I usually follow the practice that when one of my classes owns an IDisposable
object then it also implements IDisposable
and calls Dispose
on the owned object. However recently I came across a class which implemented IDisposable
explicitly thus preventing me from directly calling Dispose
forcing me to cast it which I found annoying and unnecessary.
So the question: Why and when would one want to use an explicit interface implementation of IDisposable
? I know that there are perfectly good and valid reason for implementing an interface explicitly but in regards to IDisposable
the reason is not quite clear to me.