在vb.net中,如果在现有对象上初始化了新对象,这会丢弃旧对象还是只是取消引用它,而将其保留在内存中?
例如:
public Class MainClass
dim someObject as someClass
private sub FormLoadEvent()
'initialize the object the first time
someObject = new someClass
'initialize a new copy of the class using the same variable
someObject = new someClass
End Sub
End Class
其中的“ someClass”是实现iDisposable的类,例如字体和钢笔之类的绘图对象。
编辑:我找到了What happens to the old object if you set a variable equal to a new object?,但它与c ++有关。同样适用于这里吗?