Why am I getting an “inaccessible due to protection level” error?
问题 I am getting this error: 'CTest.A.A()' is inaccessible due to its protection level. when compiling this code: public class A { private A() { } } public class B : A { public void SayHello() { Console.WriteLine("Hello"); } } Can anyone explain why? 回答1: Because the default constructor for A is private, try protected A() {} as the constructor. Class B automatically calls the default constructor of A , if that is inaccessible to B or there is no default constructor (if you have constructor