Can't make a public class from an inner class?

I have an inner class:

internal abstract class Reader
{
    //internal abstract void methods
}

I can not do this class:

public abstract class CustomFileReader : Reader
{
}

Because it is more visible than the class to which it inherits. I want to do this to ensure that you inherit from the public inheritance of the Reader class, not the base class. Is this possible, or do I need to set the base class?

+4
source share
1 answer

You cannot have a class internalin the class inheritance tree public, but you can force users to output from CustomFileReaderinstead Readerby creating a single Readerinternal constructor :

public abstract class Reader
{
    internal Reader()
    {
    }
}

public abstract class CustomFileReader : Reader
{
    // Public and protected constructors here
}

, Reader , , .

+11

Source: https://habr.com/ru/post/1539026/


All Articles