Thursday, 17 June 2010

differace between Overridable AND Overrides

Public MustInherit Class overridesk


Public Overridable Function Result(ByVal i As Integer, ByVal j As Integer) As Integer
Result = i / j
End Function

Public MustOverride Function add() As Integer

End Class



Class kk
Inherits overridesk
Public Overrides Function add() As Integer

End Function


Public Overrides Function Result(ByVal i As Integer, ByVal j As Integer) As Integer
Result = i + j
End Function
End Class


button!.click
====================
Dim abs As New kk()

abs.Result(1, 3)

===================

----> In VB.NET WRITE ABSTRACT CLASS DECLARE CLASS MustInherit
----> in parent class u write overridable function there is no need must declare ovverrides
----> but u want write overrides in derived class u must declare parent class overridable which function u want
-----> and u decalre parent class mustoverride fuction there is also complsary need to derrived class that function
EX:
PARENT
Public MustOverride Function add() As Integer

derived :
Public Overrides Function add() As Integer

End Function

No comments:

Post a Comment