Hi
im trying to use the finalize method to destroy an object , i cant seem to get the method to run since the console never
writes the line that the dog object is destroyed!
also according to the msdn net 1.1
http://msdn2.microsoft.com/en-us/library/hks5e2k6(vs.71).aspx The Finalize destructor is a protected method that can be called only from the class it belongs to, or from derived classes. The system calls Finalize automatically when an object is destroyed, so you should not explicitly call Finalize from outside of a derived class's Finalize implementation.
i would though like to know how i can the finalize method explicit ? to force destruction of an object!
Public Class Dog
'The age variable
Private Age As Integer
'This is the destructor:
Protected Overrides Sub Finalize()
Console.WriteLine("Dog is Destroyed")
End Sub
'The default constructor:
Public Sub New()
Console.WriteLine("Dog is Created With Age Zero")
Age = 0
End Sub
'The parameterized constructor:
Public Sub New(ByVal val As Integer)
Console.WriteLine("Dog is Created With Age " + Convert.ToString(val))
Age = val
End Sub
'The Main Function
Shared Sub Main()
Dim Jimmy, Jacky As Dog
'Create the objects
'This will call the default constructor
Jimmy = New Dog
'This will call the parameterized constructor
Jacky = New Dog(10)
End Sub
End Class
thanks
vbturbo