Imports System
Imports System.Runtime.InteropServices
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.IO
Imports System.Xml.Serialization
Public Class MainClass
Shared Sub Main(ByVal args As String())
Dim i As Integer = 0
i += 1
Dim obj As New Named("Dispose " & i)
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
' Free resources.
Protected Overrides Sub Finalize()
Dispose()
End Sub
' Display our name.
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
|