I just started to learn C# and noticed that there are a lot of classes that implement IDisposable
interface. The problem, as I see it, is that it's very easy to forget to call Dispose
. The compiler/editor does not show any warnings. Is there something that can be done here?
var Thing = new DisposableThing();
class DisposableThing : IDisposable
{
public void Dispose()
{
Console.WriteLine("Disposal is done");
}
}