Re: How to call a method defined in grandparent class?
- From: Lasse Vågsæther Karlsen <lasse@xxxxxxxxxxx>
- Date: Mon, 26 Nov 2007 14:03:19 +0100
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/
.
- Follow-Ups:
- Re: How to call a method defined in grandparent class?
- From: Jon Skeet [C# MVP]
- Re: How to call a method defined in grandparent class?
- References:
- How to call a method defined in grandparent class?
- From: Curious
- Re: How to call a method defined in grandparent class?
- From: bj7lewis
- Re: How to call a method defined in grandparent class?
- From: Jon Skeet [C# MVP]
- How to call a method defined in grandparent class?
- Prev by Date: Re: How to call a method defined in grandparent class?
- Next by Date: Re: How to call a method defined in grandparent class?
- Previous by thread: Re: How to call a method defined in grandparent class?
- Next by thread: Re: How to call a method defined in grandparent class?
- Index(es):
Relevant Pages
|