I'm learning to draw stuff in C# and I keep seeing recommendations to use dispose(), but I don't quite understand what it does.
IDisposable
, you should call Dispose
just before it becomes eligible for garbage collection. As others have pointed out, it's best to use the using
statement instead of calling Dispose
directly.StreamWriter
). For this reason, it's best to always dispose any class that implements IDisposable
, as a general rule.Dispose
before you are done with the object, and then attempt to use the disposed object, you will get an ObjectDisposedException
.