Generic Disposal (Of T) Tips & Tricks
Tips/Tricks The following code example shows a custom generic disposal Public Sub DisposeObjects(Of T As IDisposable)(ByRef disposableObject As T) Dim disposable As IDisposable = CType(disposableObject, T) disposableObject = CType(Nothing, T) If (disposable IsNot Nothing) Then disposable.Dispose() End If End Sub Usage: Dim any as Foo = New Foo DisposeObjects(CType(any, Foo))