publicclass Test
public Shared Sub Main
Dim obj As New Named("Dispose ")
obj.Dispose()
End Sub
End class
Public Class Named
Implements IDisposable
Public Name As String
Public Sub New(ByVal new_name As String)
Name = new_name
End Sub
Protected Overrides Sub Finalize()
Dispose()
End Sub
Public Sub Dispose() Implements System.IDisposable.Dispose
Static done_before As Boolean = False
If done_before Then Exit Sub
done_before = True
Console.WriteLine(Name)
End Sub
End Class