acadam said:
Public MustInherit Class A
Public Sub method1()
...
End sub
End Class
Partial Class B
Inherits A
Public Sub method1()
...
End sub
End Class
The compiler should be warning you about Shadowing method1(). IMHO,
Shadowing is a Bad Thing and should generally be avoided.
If you want to be able to change the behaviour of a method in a derived
class then mark the method as Overridable in the base class and
overrides in the derived class, as in:
Mustinherit Class A
Overridable Sub method1()
Class B
Inherits A
Overrides Sub method1()
I create an instance of B, but when I call methodA, I would like that
1. would be executed method1 - base class A
2. then would be executed method1 - derived class B
is it possible? how?
Yes; I don't know the "proper" term for it, but I call it "extending" a
method:
When you override a method, the Framework "unplugs" the original
implementation (from the base class) and "plugs in" your replacement
implementation (from your derived class) but the original is still
hanging around [somewhere] and you /can/ call it:
Overrides Sub method1()
' class the vase implementation
MyBase.method1()
' Now you can do something extra
End Sub
Or, perhaps, you might want to do something else /first/, and then go
back to the base implementation (this is a common model when handling
events in Control-derived classes).
Overrides Sub OnDoubleClick(e as EventArgs)
If Not Me.IgnoreDoubleClick Then
MyBase.OnDoubleClick( e )
End If
End Sub
HTH,
Phill W.