469,591 Members | 2,064 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,591 developers. It's quick & easy.

Preventing hiding of a method or overriding at the base class

Any thoughts on how a method on a base class can be prevented from
being overriden or hidden?

Basically the idea is that no matter what all derived classes should
use the method in my base class. Got to prevent hiding via the new
keyword as well.

Nov 17 '05 #1
1 1434
Tariq,

You can prevent overriding a method easily, just don't declare it as
virtual or abstract. However, you can not prevent someone deriving from
your class from shadowing a method. There is just no way to do it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tariq" <ta*******@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Any thoughts on how a method on a base class can be prevented from
being overriden or hidden?

Basically the idea is that no matter what all derived classes should
use the method in my base class. Got to prevent hiding via the new
keyword as well.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.