I have an internal class:
internal abstract class Reader
{
//internal abstract void methods
}
I cannot make this class:
public abstract class CustomFileReader : Reader
{
}
Because it is more visible than the class it inherits from. I want to do this to enforce that you must inherit from a publicly accessible inheritor of the Reader class and not the base class. Is this possible or do I have to expose the base class?
You can't have an internal
class in the inheritance tree of a public
class, but you can force users to derive from CustomFileReader
instead of Reader
, by making the only constructor of Reader
internal:
public abstract class Reader
{
internal Reader()
{
}
}
public abstract class CustomFileReader : Reader
{
// Public and protected constructors here
}
Now anything which tries to inherit directly from Reader
outside your assembly will be told that it can't find an accessible base class constructor.
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