I was using the FtpWebResponse class and didn't see a Dispose method. It turns out that the class implements IDisposable, but does so explicitly so that you must first cast your instance to IDisposable before calling Dispose:
// response is an instance of FtpWebResposne
((IDisposable) response).Dispose();
Why would the designer of a class such as this one choose to implement IDisposable explicitly? As Anthony Pegram says, doing things this way masks the fact that the object should be disposed for the average developer who is not consulting the documentation every time he/she uses a class.
This is normally done if the class has a Close
method that is the exact same as Dispose
. The original Dispose
is hidden in an explicit implementation so that the exact same method doesn't have two names.
It's officially recommended here:
(P.S. I disagree with this convention.)