What is the meaning of the planned “private protected” C# access modifier?

前端 未结 6 1398
名媛妹妹
名媛妹妹 2020-12-02 05:49

As part of the Roslyn documentation on GitHub, there\'s a page called Language feature implementation status, with planned language features for C# and VB.

One featu

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 06:24

    It's just a guess, but from a name you could possibly guess it's a more restricted version of protected, (or more relaxed version of private if you wish). And only reasonable variant of it is restricting protected behaviour to assembly.

    Possible usage: then you want to have protected for internal implementation, but not for external uses (and you don't want sealing the class).

    P.S. It always existed in CLR, but not in C#. It's a combination of protected and internal, quote:

    CLR also supports “Family and assembly” access type. This means that the method is accessible from within the declaring type, nested and derived types but only if they’re declared in the same assembly. Well, apparently C# team didn’t think of this as a very useful feature so it’s not supported in this language.

提交回复
热议问题