HttpWebReponse
implements IDisposable
interface, but why is there no Dispose
method. It only contains Close
method. Will
HttpWebResponse implements IDisposable interface explicitly. So you can call Dispose
only when you cast HttpWebResponse to IDisposable
. The Close
method of HttpWebResponse calls Dispose internally.
HttpWebResponse response = // assigned from somewhere
IDisposable disposableResponse = response as IDisposable;
disposableResponse.Dispose();
Since HttpWebResponse
implements IDisposable
you can use it with an using-statement.
HttpWebResponse response = // assigned from somewhere
using(response) {
// do your work;
}