Can I please clarify what is best practice with the destruction of
class member variables.
Say I have a member variable that has a default value (as shown
below), then should we set this to null on the Dispose method (if
applicable) - say in a WinForm. Otherwise should we derive it from
IDisposable and set it to null in Dispose method (the hassle is
ensuring that the Dispose gets called)? Alternatively, put in the
finalize method.
Up until now, we have typically left 'as is' with no cleanup as we
thought the GC would destory. However, it appears to be taking ages
to get destroyed
class ClassX
{
ClassY y = new ClassY();
}
class ClassY
{
...
}