I need some clarification on…
… how the CLR — more specifically, the garbage collector — finds the classes which implement the IDisposable interface; and
… how it calls the Dispose method (of all classes which implement the IDisposable interface) to free up memory?
The CLR does not call Dispose(), this is up to user code to call either directly or through the use of the using statement. The CLR will however call finalizers, although this is not gauranteed.
Dispose is not called automatically. The compiler generates calls to Dispose when you write using, or call Dispose directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With