如果在调用方法时创建画笔,是否会释放画笔
下面是在我的绘制方法中找到的代码片段。当我以这种方式创建一个像画笔这样的对象时,我不确定它叫什么,但无论如何它都会被正确处理,或者我是否需要关心它?
g.DrawString("12", _ContentFont, new SolidBrush(Color.Black), new PointF(25, 25));
below is a fragment of code that is found in my paint method. I am not sure what it is called when I create an object such as the brush this manner, but never the less will it be disposed of properly, or do I need to be concerned about it?
g.DrawString("12", _ContentFont, new SolidBrush(Color.Black), new PointF(25, 25));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,不会的。试试这个:
但是当谈到黑色时,最好是:
No, it won't. Try this instead:
But when it comes to black, it is even better to just:
不会。它有资格进行处置。无法保证这种情况何时真正发生;它可能会持续相当长一段时间。
这些天我会认为这是一个错误,尽管我也知道有时我也不太了解。
No. It becomes eligible for disposal. There's no guarantee on when that actually happens; it could could hang around for quite some time.
These days I would consider that a bug, though I know of time when I didn't know any better, either.