'自訂建構子(參數) Public Sub New(ByVal _id As String, ByVal _name As String, ByVal _brithDate As DateTime) '隱含編譯指向父親空參數 Me._id = _id Me._name = _name If (_brithDate <= DateTime.Now) Then Me._birthDate = _brithDate End If End Sub '建構子OverLoading Public Sub New() '隱含編譯指向父親空參數 End Sub '解構子OverLoading Overrides Protected Sub Finalize() Console.Writeline ("Dog is Destroyed") End SuPublic Sub New() '隱含編譯一行指向父親空參數 MyBase.New("", "", "2000/1/1", "") System.Console.WriteLine("業務員建構!!") End Sub '參數 Public Sub New(ByVal _id As String, ByVal _name As String, ByVal _birthDate As DateTime, ByVal _sex As String, ByVal _qa As Decimal) '部分父親建構 MyBase.New(_id, _name, _birthDate, _sex) Me._qa = _qa End Sub'Overridable 允許子類別可以進行複寫 Public Overridable Overloads Function calSalary() As Decimal Return Me._salary End Function '想改寫父親有的 method calSalary() Public Overrides Function calSalary() As Decimal Dim b As Decimal = MyBase.calSalary() '原來底薪 Me._salary = b + Me._bon End Function
from
http://www.dotblogs.com.tw/timothy/archive/