Re: How to call a method defined in grandparent class?



Jon Skeet [C# MVP] wrote:
On Nov 26, 6:58 am, "bj7lewis" <bj7le...@xxxxxxx> wrote:

<snip>

So now to access your derived grandparent base class you can use...

...
//in some function...
//base.base.Show();
((GRANDPARENTBASECLASSHERE)TextBoxObj).Show();

No, that won't do it, because overriding is done at runtime, not
compile time. If a method is overridden in a child class, the
grandchild cannot access the original behaviour.

Jon

Which, IMO, is a good thing. Otherwise, the contract that the child-class guarantees with its implementation goes out the window if a descendant could skip its code entirely.

--
Lasse Vågsæther Karlsen
mailto:lasse@xxxxxxxxxxx
http://presentationmode.blogspot.com/
.



Relevant Pages


Quantcast