April 2018
Intermediate to advanced
300 pages
7h 41m
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 ...