Say I have a 3D double array 3dArray, and a variable of custom type Person person1. Doing this:
3dArray = null;
person1 = null;
works but looks sloppy and doing this:
3dArray = person1 = null;
as throws an error as 3dArray and person1 can't be implicitly converted. Is there a better way to do this in one line?
IDisposable()when applicable and just let the rest happen. By setting the variable to null you could actually be extending the life of it and preventing the GC from doing its jobIDisposableis not responsible for releasing memory, that is the job of the garbage collector. Setting a variable to null is not necessary as the gc will know if the object is no longer reachable and will collect it as needed. When this happens is not deterministic. It should happen when there is memory pressure.