VB.NET在子例程的参数中使用“ New”语句创建的资源范围

问题描述 投票:0回答:1

我想知道,在VB.NET中是:

Using tBrush = New SolidBrush(UseColor)      
  e.Graphics.FillRectangle(tBrush, someRect)    
End Using

相当于:

e.Graphics.FillRectangle(New SolidBrush(UseColor), someRect)   

即。在第二种情况下,将在FillRectangle完成后立即释放SolidBrush吗?

vb.net scope new-operator dispose using
1个回答
0
投票

简短的回答,是的,它们是等效的。是的,第二支刷子将被释放,垃圾收集器将在某个时候得到它。

© www.soinside.com 2019 - 2024. All rights reserved.