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
?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With