C
Claire
How do I make sure Ive disposed of my objects please?
Ive added interface IDispose to a base class.
Ive several sub classes inheriting from this base class.
I store one or other of these subclasses in a variable and call dispose(),
but the Dispose() method of the base class is called rather than in the sub
class
example
class baseclass : IDisposable
{
public void Dispose()
{
this is always called
}
}
class SubClass:baseclass
{
public void Dispose()
{
this is never called
}
}
baseclass aclass = null;
SubClass anotherclass = new SubClass();
aclass = anotherclass;
aclass.Dispose();<< this calls baseclass.dispose rather than
subclass.dispose;
Ive added interface IDispose to a base class.
Ive several sub classes inheriting from this base class.
I store one or other of these subclasses in a variable and call dispose(),
but the Dispose() method of the base class is called rather than in the sub
class
example
class baseclass : IDisposable
{
public void Dispose()
{
this is always called
}
}
class SubClass:baseclass
{
public void Dispose()
{
this is never called
}
}
baseclass aclass = null;
SubClass anotherclass = new SubClass();
aclass = anotherclass;
aclass.Dispose();<< this calls baseclass.dispose rather than
subclass.dispose;