c# - Overriding an abstract method with a virtual one -


I'm trying to override an abstract method in an abstract class with a virtual method in a child class . I understand the difference between abstract and virtual methods (assumed so far?)

Obviously I am not able to do this, but my question is ... why? Based on the accepted answer and this scenario, I just do not see the problem:

  Public Intangible class TopLevelParent {protected abstract void TheAbstractMethod (); } Public class FirstLevelChild1: TopLevelParent {protected override void TheAbstractMethod () {}} public class FirstLevelChild2: TopLevelParent {date protected virtual override void TheAbstractMethod () {// Here's some stuff}} public class SecondLevelChild: FirstLevelChild2 does not require {// Here to apply the method again ... My parents do it the way I need it}  

Then obviosuly what two of my inherited children and another class in them With one from inherited There is a high-level parent. Then, depending on the link I accepted in the post above, on the basis of the answer:

"A virtual function, basically, look here can be good for functionality or not child class. is. so if it's good enough, then use this method, if not, to override me, and to provide its functionality. "

and the second level of the child virtual Get the method from her parents , Thus satisfying the need for implementation of the abstract pattern of the top-most parent ... What's the problem?

I have no problem in my understanding of this ...

Observe a method is indirectly virtual (not in the sense that it can be overridden in a subclass), marked as

: < / p>

  public class FirstLevelChild1: TopLevelParent {protected override void TheAbstractMethod () {}} public class SecondLevelChild1: FirstLevelChild1 {protected override void TheAbstractMethod () {} // No problem} common Nick class FirstLevelChild2: TopLevelParent {protected seal zero TheAbstractMethod () {override}} public class SecondLevelChild: FirstLevelChild2 {protected override void TheAbstractMethod () {} // error: inherited can not override member // The 'FirstLevelChild2.TheAbstractMethod ( ) 'Because it is stamped)  

Comments