I have an internal abstract class InternalClassBase
and two (also internal) classes InternalClass1
and InternalClass2
, which inherit from InternalClassBase
.
I also have a public abstract class PublicClassBase
and two (also public) classes PublicClass1
and PublicClass2
, which inherit from PublicClassBase
.
The PublicClassBase
has a protected member XXX
of type InternalClassBase
, so both PublicClass1
and PublicClass2
can use it.
This is my code:
internal abstract class InternalClassBase { }
internal class InternalClass1 : InternalClassBase { }
internal class InternalClass2 : InternalClassBase { }
public abstract class PublicClassBase
{
protected InternalClassBase XXX; // this is where the error happens
}
public class PublicClass1 : PublicClassBase { }
public class PublicClass2 : PublicClassBase { }
Why can't PublicClassBase
contain the XXX
member in my example? I thought that XXX
would only be visible within PublicClassBase
, PublicClass1
and PublicClass2
, but not outside of it.
I also thought that I understand access modifiers, but obviously I don't :)
Edit - the error happens at declaration of XXX inside PublicClassBase, and the exception message is: Inconsistent accessibility: field type 'ClassLibrary2.InternalClassBase' is less accessible than field 'ClassLibrary2.PublicClassBase.XXX', but how can protected be more accessible then internal?