c# - Is object eligible for garbage collection if it's created within using-statement and not explicitly bound to a reference? -


i have (illustration only) c# code:

using( new system.io.memorystream() ) {     system.threading.thread.sleep(1000); } 

note here memorystream created , not explicitly bound reference. unless there's special treatment because of using statement object has no references , collected before control leaves using statement , maybe before sleep() completes.

is memorystream eligible collection before control leaves using statement?

no, not.

behind scenes, hidden reference memorystream has been created, still alive.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -