Constructors / Destructors
In vb.net & c# language Constructors / Destructors are differ. Code of Constructors / Destructors of vb.net & c# language.
____________________________________________________________________
Class SuperHero
Private _powerLevel As Integer
Public Sub New()
_powerLevel = 0
End Sub
Public Sub New(ByVal powerLevel As Integer)
Me._powerLevel = powerLevel
End Sub
Protected Overrides Sub Finalize()
' Desctructor code to free unmanaged resources
MyBase.Finalize()
End Sub
End Class
C#
class SuperHero {
private int _powerLevel;
public SuperHero() {
_powerLevel = 0;
}
public SuperHero(int powerLevel) {
this._powerLevel= powerLevel;
}
~SuperHero() {
// Destructor code to free unmanaged resources.
// Implicitly creates a Finalize method
}
}
-------------------------------------------------------------------------------------------------
Note: This code applicable for both desktop and web application.
No comments:
Post a Comment