Is it possible to prevent inheritance of an abstract class

abstract-class, c#, inheritance

Solution

To elaborate a little on my comment. This isn't supported, so the answer is no. The only contrived way of trying this that comes to mind (that obviously wouldn't work) would be to have a `sealed abstract` class, which is nonsensical, as neither `A` nor `B`, nor anything else, could then inherit either.

There is no discriminator that allows us to say, "sealed for", for instance.

Problem

Consider the code: ``` public abstract class Base { public Dictionary<int, string> Entities { get; private set; } protected Base() { Entities = new Dictionary<int, string>(); } } public abstract class A : Base { public abstract void Update(); } public abstract class B : Base { public abstract void Draw(); } ``` Is it possible to restrict classes (in the same assembly) from inheriting from `Base`, forcing them to inherit from either `A` or `B`?

Original source