class myApp
Public Shared Sub Main()
Resource r1 = new Resource()
Try
' Do something with the object.
r1.DoSomething()
Finally
' Check for a null resource.
If Not (r1 is Nothing) Then
' Call the object's Dispose method.
r1.Dispose()
End If
End Try
End Sub
End Class