3 ms·
>In case you forget the GC will call Dispose but it's entirely up to the GC when that happens, so personally I wouldn't say it's similar. This actually has to
by SigmundA 3y ago
>In case you forget the GC will call Dispose but it's entirely up to the GC when that happens, so personally I wouldn't say it's similar.
This actually has to be implement in the classes finalizer its not done automatically. The finalizer is called by the GC which if the designer chooses can call Dispose. This is usually done in well designed classes that use unmanaged resources.
Dispose and using give you the determinism if you want it and the finalizer gives you the backstop to prevent leaks if it makes sense.
- magicalhippo 3y agoGood point, I forgot about that little, but crucial, detail. So it's flexible, but there are footguns about, especially if you're wrapping a handle to something external.