【问题标题】:Using Block WIth System.Drawing.Graphics使用带有 System.Drawing.Graphics 的块
【发布时间】:2011-06-29 05:29:11
【问题描述】:

我想知道下面的代码块是否安全,这意味着 gfx 处置本身是否会出错?

Using gfx As Graphics = Graphics.FromImage(img)
    gfx.Clear(Color.Transparent)
    gfx.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
End Using

【问题讨论】:

    标签: system.drawing


    【解决方案1】:

    是的,这就是using 关键字的全部意义所在。来自here

    Using 块保证处置 一种或多种这样的资源,当 您的代码已完成。这个 使它们可用于其他代码 使用。

    【讨论】:

    • 感谢您确定这也是真正的 Graphics 对象。
    猜你喜欢
    • 1970-01-01
    • 2011-09-08
    • 1970-01-01
    • 2013-06-09
    • 2012-10-24
    • 2021-09-28
    • 2018-02-22
    • 2011-10-21
    相关资源
    最近更新 更多