防止单个方法覆盖在C#

防止单个方法覆盖在C#

问题描述:

我知道,我可以使用密封,以防止其他类继承一定的阶级,
但有可能允许继承,但阻止某些虚拟方法压倒一切的?

I know that I can use the sealed in order to prevent other classes to inherit a certain class, but is it possible to allow inheritance but prevent overriding of some virtual methods?

只有虚拟方法可以被覆盖。结果
就离开了虚拟,和你的方法不会重写。

Only virtual methods can be overridden.
Just leave out virtual, and your method will not be overridable.