c# - Using operator sealed with the members of the class -


i've found in troelsen's book, operator sealed can used on members of class protect virtual methods override.

but if don't want override virtual methods, sense make virtual?

you might have situation this:

public class {     public virtual void mymethod()     {         //...     } }   public class b : {     public override void mymethod()     {         //...     } }   public class c : b {     public override void mymethod()     {         //...     } } 

but if want inheriting class c not able override b's mymethod, while still allowing b override a's? can do:

public class b : {     public sealed override void mymethod()     {         //...     } } 

with change made, can no longer override method in c.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -