Destructor in

Posted by Satyapriyanayak under VB.NET category on | Points: 40 | Views : 2541
Destructor release the memory of the object created by the constructor. It is of two types dispose and finalize .In dispose we have to intentionally call dispose destructor. But in finalize it is called automatically when the last reference of the object is released 


Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As New raj
End Sub
Public Class raj
Public Sub New()
MsgBox("Instant constructor of raj")
End Sub
Shared Sub New()
MsgBox("Shared constructor of raj")
End Sub
Public Overloads Sub dispose()
MsgBox("Dispose destructor of raj")
End Sub
Protected Overrides Sub finalize()
MsgBox("Finalize destructor of raj")
End Sub
End Class
End Class

Comments or Responses

Login to post response