简体   繁体   English

访问修饰符C# - 内部修饰符

[英]access modifiers C# - internal modifier

From MSDN ,Internal : Access is limited to the current assembly. 从MSDN,内部:访问被限制在当前装配。

so if i have single project winform1 , will using internal modifier mean access to any class in my project? 所以,如果我有单个项目winform1,将使用内部修饰符意味着访问我的项目中的任何类?

I mean in a single project , will the current project context and current assembly mean the same? 我的意思是在一个项目中,当前项目上下文和当前程序集是否相同?

In a single project , will the current project context and current assembly mean the same? 在单个项目中,当前项目上下文和当前程序集是否相同?

Yes. 是。

As long as you really have only 1 project, internal and public are the same. 只要你真的只有一个项目, internalpublic都是一样的。 But do realize that in any non-trivial project you sooner or later will want to sub-divide in multiple assemblies. 但要意识到,在任何非平凡的项目中,您迟早都希望在多个程序集中进行细分。 So you might as well prepare for that and use these modifiers correctly. 所以你不妨为此做好准备并正确使用这些修饰符。 That means make (almost) every class internal . 这意味着(几乎)每个班级internal It is the default for a reason. 这是默认的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM