Say I have the following:
public abstract class ControlLimitBase : IDisposable
{
}
public abstract class UpperAlarmLimit : ControlLimitBase
{
}
public cl
Dispose()
is never called automatically - it depends on how the code is actually used.
1.) Dispose()
is called when you specifically call Dispose()
:
myAlarm.Dispose();
2.) Dispose()
is called at the end of a using
block using an instance of your type.
using(var myAlarm = new CdsUpperAlarmLimit())
{
}
The using
block is syntactic sugar for a try/finally
block with a call to Dispose()
on the object "being used" in the finally block.