c# - Why am I getting an "inaccessible due to protection level" error? -


I am getting this error:

'CTest.AA ()' is unavailable

  Public class A {Private A () {}} Public class B: A {public Zero Sehelo () {console .WriteLine ("Hello"); }}   

Why can anyone explain why?

By default the constructor for A is private, as a constructor protected A () {} Try it.

Class B automatically calls the default constructor of A , if it is not accessible for B Or there is no default constructor (if you have a constructor protected A (string s) {} ) B can not be started correctly.

The compiler automatically generates the following default constructor in

Where is the real call to the constructor of base () real a .

Comments