Hi,
My question is why do I need IDisposable? I have a class that consumes some resources that need to be freed. I have two options
Without IDisposable
class SomeUtilityClass
{
public Stop()
{
// free resources
}
}
With IDisposable
class SomeUtilityClass, IDisposable
{
public void Dispose()
{
// free resources
}
}
So why do I need IDisposable here? It does not matther how to name the function.
class Program
{
public Main(..)
{
SomeUtilityClass _class = new SomeUtilityClass();
// clean up when we've done
_class.Stop();
// OR
_class.Dispose();
}
}