This way each object's needed cleanup is encapsulated in each objects dispose method(s).
Granted using compiles down to a try-catch-finally with the Dispose method called in the finally, but there is an elegance to it.
https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...
This way each object's needed cleanup is encapsulated in each objects dispose method(s).
Granted using compiles down to a try-catch-finally with the Dispose method called in the finally, but there is an elegance to it.
https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...