Public class is inaccessible due to its protection level

后端 未结 3 1271
情歌与酒
情歌与酒 2020-12-29 18:45

I have the following classes:

namespace Bla.Bla 
{
    public abstract class ClassA 
    {
        public virtual void Setup(string thing) 
        {
                


        
3条回答
  •  轮回少年
    2020-12-29 19:05

    This error is a result of the protection level of ClassB's constructor, not ClassB itself. Since the name of the constructor is the same as the name of the class* , the error may be interpreted incorrectly. Since you did not specify the protection level of your constructor, it is assumed to be internal by default. Declaring the constructor public will fix this problem:

    public ClassB() { } 
    

    * One could also say that constructors have no name, only a type; this does not change the essence of the problem.

提交回复
热议问题