我正在为一个类实现IDisposable接口,而在释放资源时,有一个内部的可释放对象列表。我应该通过循环来释放这些对象吗?
public Class MyDisposable
Implements IDisposable
private _disposbaleObjects as new List(of OtherDisposables)
Public Overloads Sub Dispose() Implements System.IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
? Should I dispose the the list like this ?
For Each obj In _disposbaleObjects
obj.dispose()
Next
End If
End If
Me.disposedValue = True
End Sub
End Class