C# protected members accessed via base class variable [duplicate]
This question already has an answer here: Why can't I access C# protected members except like this? 7 answers It may seems rather newbie question, but can you explain why method Der.B() cannot access protected Foo via Base class variable? This looks weird to me: public class Base { protected int Foo; } public class Der : Base { private void B(Base b) { Foo = b.Foo; } // Error: Cannot access protected member private void D(Der d) { Foo = d.Foo; } // OK } Thanks! This is a frequently asked question. To figure out why this is illegal, think about what could go wrong. Suppose you had another