C# access modifier for exposing class only within namespace

前端 未结 3 374
情书的邮戳
情书的邮戳 2020-12-18 17:46

In java you have package level protection that ensures classes are only usable within the package.

Namespaces in C# act more or less like packages. But C# does not

3条回答
  •  被撕碎了的回忆
    2020-12-18 18:06

    Is there a specific reason for this?

    Mostly, it's because there are some key differences between packages and namespaces

    To simplify what's already been said in the linked question and here: Namespaces in C# are mostly to help with organizing an assembly's contents, both internally and externally. Java packages have more in common with C# assemblies, and there is an access modifier in C# that restricts to the assembly level: internal.

提交回复
热议问题