M
Mark Rae
Hi,
Following on from the recent thread about why HttpWebRequest doesn't
implement the IDisposable interface, I got to wondering whether people make
their custom classes inherit IDisposable or not as a general rule, or only
under certain circumstances...
Since it's an easy enough thing to do
(http://msdn2.microsoft.com/en-us/library/system.idisposable.aspx), is there
any good reason not to make every custom class IDisposable, the same way as
there's no good reason not to use exception handling in every method...?
I can understand the rationale for implementing IDisposable for classes
which e.g. use unmanaged resources, or which open files and/or streams,
because the GC won't know about them, but what about for classes which use /
reference only managed code? Would it be overkill to make those classes
IDisposable, and would it simply be enough to destroy references to them by
variables which have instantiated them to null...?
Interested to know your opinions...
Mark
Following on from the recent thread about why HttpWebRequest doesn't
implement the IDisposable interface, I got to wondering whether people make
their custom classes inherit IDisposable or not as a general rule, or only
under certain circumstances...
Since it's an easy enough thing to do
(http://msdn2.microsoft.com/en-us/library/system.idisposable.aspx), is there
any good reason not to make every custom class IDisposable, the same way as
there's no good reason not to use exception handling in every method...?
I can understand the rationale for implementing IDisposable for classes
which e.g. use unmanaged resources, or which open files and/or streams,
because the GC won't know about them, but what about for classes which use /
reference only managed code? Would it be overkill to make those classes
IDisposable, and would it simply be enough to destroy references to them by
variables which have instantiated them to null...?
Interested to know your opinions...
Mark