user3164272
user3164272

Reputation: 575

Inconsistent accessibility: base class (interface) is less accessible than child class

I have the following -

public interface IAView
{

}

public class BController<TView>
{

}

public interface IAController
{

}

I am accessing these classes througn a derived class which is

public class D : BController<IAView>, IAController
{

}

When I try to compile the program, I get an error saying "base class IAView is less accessible than class D"

Please help. I am working with MVC in Visual Studio Dot Net using C#

Upvotes: 0

Views: 3234

Answers (1)

Yacov
Yacov

Reputation: 1070

This code compiles

public interface IAView
{

}

public class BController<TView>
{

}

public interface IAController
{

}

public class D : BController<IAView>, IAController
{

}

class Program
{
    static void Main(string[] args)
    {
    }
}

If you wrap one of the classes with a private modifier - it will give you the error - as

private class PrivateClass
{
    public interface IAView
    {

    }
}

public class BController<TView>
{

}

public interface IAController
{

}

public class D : BController<PrivateClass.IAView>, IAController
{

}

class Program
{
    static void Main(string[] args)
    {
    }
}

Upvotes: 2

Related Questions