Why is internal protected not more restrictive than internal?

后端 未结 8 2135
陌清茗
陌清茗 2020-12-08 04:33

I\'d like to create an internal auto-property:

internal bool IP { get; protected internal set; }

I thought it would be possible to make the

相关标签:
8条回答
  • 2020-12-08 05:13

    I would consider this cheating, since Eric Lippert is on SO himself, but he wrote an excellent blog post that considers this issue.

    Why Can't I Access A Protected Member From A Derived Class, Part Three

    Ultimately, his answer is largely the same as those given by the posters here, but he ads some interesting reasoning behind the desgin of the language and the implementation of these features.

    0 讨论(0)
  • 2020-12-08 05:13

    protected internal means visible to classes in the same assembly, or to classes deriving from the containing class - in other words it is visible to those meeting the internal requirements OR the protected requirements, not AND. There is no access modifier meaning protected AND internal in this way.

    0 讨论(0)
提交回复
热议问题