Fist of all, I will use virtual
and override
for example, base class A has method A.do()
, inherited class B has B.do()
which overrides A's.
if I call (B as A).do()
, which do()
would it execute?
or, if there is a method void mymethod(A a) {a.do()}
, now I call it by B b; mymethod(b)
, would it execute b.do()
?
The most top override method always will be called, i.e. b.Do()
or (b as A).Do()
or ((A)b).Do()
will call B.Do()
.
I don't know a way how to call a base method from child class if child class overrides it.