开发者

Using Block WIth System.Drawing.Graphics

开发者 https://www.devze.com 2023-03-15 21:06 出处:网络
I was wondering if the following code block is safe, meaning will the gfx dispose itself is something goes wrong?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消