开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜