c# - is it possible to mark overridden method as final -


In C #, is it possible to mark the override virtual method as final, so that the implementers can not override it? How do I do this?

An example might make it easier to understand:

  class A {abstract void DoAction (); } Class B: A {Override is a way of zero deduction () {// Implementation Action that it does not mean // to override children, e.g. By setting the private state //, depending on the operation later}} class C: B {/} this will be a bug override zero DoAction () {}}  

modify B Is there any way to stop other children, by overriding the two-action, either in compile-time or runtime?

Yes, with "sealed":

  class A { Abstract zero transaction (); } Class B: A {seal override is a way from zero doAction () {// implementations action} that it does not mean // to override children, e.g. By setting the Private State //, depending on the operation later}} class C: B {override zero DoAction () {} // will not compile}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -