internal protected property still accessible from a different assembly

前端 未结 8 972
清酒与你
清酒与你 2021-02-07 09:40

I\'m setting up some demo code for a beginner session on accessibility and I found that I am able to access an internal protected property from a derived class. What am I missin

8条回答
  •  暖寄归人
    2021-02-07 10:28

    The protected keyword is a member access modifier. A protected member is accessible from within the class in which it is declared, and from within any class derived from the class that declared this member.

    http://msdn.microsoft.com/en-us/library/bcd5672a(v=vs.71).aspx

    By combining the protected and internal keywords, a class member can be marked protected internal — only derived types or types within the same assembly can access that member.

    http://msdn.microsoft.com/en-us/library/ms173121(v=vs.80).aspx

提交回复
热议问题