3 ms·
With regard to: sqlConnection.Close(); sqlConnection.Dispose(); sqlConnection = null; The irony is that the .NET Framework and it's compilers are very good at
by bdfh42 18y ago
With regard to:
sqlConnection.Close();
sqlConnection.Dispose();
sqlConnection = null;
The irony is that the .NET Framework and it's compilers are very good at optimisation and will almost certainly make the object available for garbage collection at the first opportunity - with a good chance that the second two statements would not even make it into the assembly.
- statictype 18y agoI haven't dealt with this stuff in some time, but I recall that those last two statements are actually needed. I think it was a work-around for a bug\design-flaw in the earlier .NET garbage collector. That last bit on explicitly assigning to null was really weird but in some cases, necessary.