December 2018
Beginner to intermediate
668 pages
15h 30m
English
We already know that the IDisposable interface should be used whenever we need to release unmanaged resources. However, there is a standard rule that should be considered when dealing with the disposal of objects. The rule states that if the instance within the class implements the IDisposable interface, we should implement IDisposable on the consuming class as well. For example, the preceding class DatabaseManager class uses SqlConnection, where SqlConnection implements the IDisposable interface internally. To address this rule, we will implement the IDisposable interface and invoke the instance's Dispose method.
Here is a better example that invokes the protected Dispose method from the DatabaseManager ...
Read now
Unlock full access