在这段VB.NET代码中:
为什么需要将'o'设置为'Nothing'?如果在“Finally”块中不将其设置为“Nothing”,会发生什么?我认为,如果不将其设置为“Nothing”,那么也是可以的,因为该对象将被标记为垃圾回收。
Dim o as SomeClass
Try
o = new SomeClass
'call some method on o here
Catch(...)
...
Finally
o = Nothing
End Try
为什么需要将'o'设置为'Nothing'?如果在“Finally”块中不将其设置为“Nothing”,会发生什么?我认为,如果不将其设置为“Nothing”,那么也是可以的,因为该对象将被标记为垃圾回收。