Automatic Disposing
Learn to work with types that implement the IDisposable interface.
We'll cover the following...
Introduction
It’s important to call the Dispose()
method in a robust manner by putting everything inside a try...finally
block.
Course course = null;
try
{
course = new Course() { Title = ".NET Fundamentals" };
}
finally
{
course?.Dispose();
}
However, if we have many objects in our program that use unmanaged resources, our code is filled with ...