Public Class One 'base class Public i As Integer = 10 Public j As Integer = 20 Public Function add() As Integer Return i + j End Function End Class Public Class Two Inherits One 'derived class. class two inherited from class one Public k As Integer = 100 Public Function sum() As Integer 'using the variables, function from base class and adding more functionality Return i + j + k End Function End Class Sub Main() Dim one As New One() Dim two As New Two()
WriteLine(one.add())
WriteLine(two.sum())
Read()
End SubOut Put :
30
130
No comments:
Post a Comment