I'm pretty new to c#, so i apologise if the answer to my question is painfully obvious...
I'm wondering if there is a difference between the way garbage collection treats the following two Image
object references:
Size imgSize = System.Drawing.Image.FromStream(FileUpload01.FileContent).PhysicalDimension.ToSize();
, and
Size imgSize;
using (System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload01.FileContent))
{
imgSize = img.PhysicalDimension.ToSize();
}
so in the first example, there is no stored image reference, and in the second, the using
clause should force disposal.
Will there be any difference as to when GC will be able to clean up these two images?
Thanks in advance...
[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 IDisposable
implementations).