Using Block WIth System.Drawing.Graphics
I was wondering if the following code block is safe, meaning will the gfx dispose itself is something goes wrong?
Using gfx As Graphics = Grap开发者_运维技巧hics.FromImage(img)
gfx.Clear(Color.Transparent)
gfx.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
End Using
Yes, that's the whole point of the using
keyword. From here:
A Using block guarantees the disposal of one or more such resources when your code is finished with them. This makes them available for other code to use.
精彩评论