I've created 3 classes, A, B and C.
- B inherits from A
- C inherits a Collection of A
However, I can't understand why when inheriting from a collection, the derived class can access only the protected member of the base class.
public class A
{
public int MyPublic { get; set; }
protected int MyProtected { get; set; }
internal int MyInternal { get; set; }
protected internal int MyProtectedInternal { get; set; }
}
public class B : A
{
B MyB { get; set; }
B()
{
MyB.MyProtected++;
MyB.MyInternal++;
MyB.MyPublic++;
MyB.MyProtectedInternal++;
}
}
public class C : Collection<A>
{
C MyC { get; set; }
C()
{
MyC[0].MyProtected++; // Inaccessible due to its protection level.
MyC[0].MyInternal++;
MyC[0].MyPublic++;
MyC[0].MyProtectedInternal++;
}
}