Re: Hiding inherited method
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Thu, 30 Mar 2006 18:25:00 +0100
PIEBALD <PIEBALD@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I was trying to break some polymorphism, expecting it not to work, but I'm a
curious sort.
I was seeing what happens when a derived class tries to hide an inherited
method with a private new method, expecting an error or warning; I got
neither with the result that the inherited method does _not_ get hidden (i.e.
not possibe to break polymorphism/inheritance this way, yay!)
My question then is, why is there no warning that the code may not work the
way the writer expects? Is it simply because the _new_ keyword turns it off?
Without the _new_ keyword, the warning about hiding fires, but this is a case
where no hiding will happen anyway, because the private method _does_not_
hide the inherited method.
Well, it hides it within that class - it just doesn't hide it for other
users of the class.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: Hiding inherited method
- From: Bob Milton
- Re: Hiding inherited method
- Prev by Date: Re: Accessing Protected Variable From Outside Class
- Next by Date: Re: Thumbnail of WebBrowser content
- Previous by thread: Re: Accessing Protected Variable From Outside Class
- Next by thread: Re: Hiding inherited method
- Index(es):
Relevant Pages
|