C# accessing protected member in derived class [duplicate]
问题 This question already has answers here : Why can't I access C# protected members except like this? (7 answers) Closed 6 years ago . I wrote the following code: public class A { protected string Howdy = "Howdy!"; } public class B : A { public void CallHowdy() { A a = new A(); Console.WriteLine(a.Howdy); } } Now, in VS2010 it results in the following compilation error: Cannot access protected member 'A.a' via a qualifier of type 'A'; the qualifier must be of type 'B' (or derived from it). This