4 ms·
When mentioning C# (not sure about any other language), I would have mentioned the using statement and IDesposable objects. This way each object's needed clean
by hateful 7y ago
When mentioning C# (not sure about any other language), I would have mentioned the using statement and IDesposable objects.
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-reference/keywords/using-statement https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...