Preventing hiding of a method or overriding at the base class

T

Tariq

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.
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top