internal protected property still accessible from a different assembly

前端 未结 8 1141
清酒与你
清酒与你 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:34

    Because it's how internal protected is intended to work. Access is given for either children in inheritance tree (protected part) or for the same assembly (internal part) - see Access Modifiers on MSDN.

    And your ExampleClass is in the inheritance tree of BaseClass, which defines Prop5. So the access is thanks to protected part.

提交回复
热议问题