title: How does Garbage Collection treat objects that go out of scope?
body: <p>I'm pretty new to c#, so i apologise if the answer to my question is painfully obvious... </p>
  
  <p>I'm wondering if there is a difference between the way garbage collection treats the following two <code>Image</code> object references:</p>
  
  <pre><code>Size imgSize = System.Drawing.Image.FromStream(FileUpload01.FileContent).PhysicalDimension.ToSize();
  </code></pre>
  
  <p>, and</p>
  
  <pre><code>Size imgSize;
  using (System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload01.FileContent))
  {
      imgSize = img.PhysicalDimension.ToSize();
  }
  </code></pre>
  
  <p>so in the first example, there is no stored image reference, and in the second, the <code>using</code> clause should force disposal.</p>
  
  <p>Will there be any difference as to when GC will be able to clean up these two images?</p>
  
  <p>Thanks in advance...</p>
  
  <p>[EDIT:] To be clear, since this was flagged as duplicate, my question is how GC treats the image object in the first example, since after that statement has executed, i can no longer access the image object. (i think this is different from a general discussion on GC's treatment of <code>IDisposable</code> implementations).</p>