1. <small id='6SA54'></small><noframes id='6SA54'>

      1. <legend id='6SA54'><style id='6SA54'><dir id='6SA54'><q id='6SA54'></q></dir></style></legend>
      2. <i id='6SA54'><tr id='6SA54'><dt id='6SA54'><q id='6SA54'><span id='6SA54'><b id='6SA54'><form id='6SA54'><ins id='6SA54'></ins><ul id='6SA54'></ul><sub id='6SA54'></sub></form><legend id='6SA54'></legend><bdo id='6SA54'><pre id='6SA54'><center id='6SA54'></center></pre></bdo></b><th id='6SA54'></th></span></q></dt></tr></i><div id='6SA54'><tfoot id='6SA54'></tfoot><dl id='6SA54'><fieldset id='6SA54'></fieldset></dl></div>
        <tfoot id='6SA54'></tfoot>
        • <bdo id='6SA54'></bdo><ul id='6SA54'></ul>

        仅在命名空间内公开类的 C# 访问修饰符

        C# access modifier for exposing class only within namespace(仅在命名空间内公开类的 C# 访问修饰符)
        • <bdo id='HtYmk'></bdo><ul id='HtYmk'></ul>
              <tbody id='HtYmk'></tbody>

                <tfoot id='HtYmk'></tfoot>
                • <small id='HtYmk'></small><noframes id='HtYmk'>

                • <legend id='HtYmk'><style id='HtYmk'><dir id='HtYmk'><q id='HtYmk'></q></dir></style></legend>
                  <i id='HtYmk'><tr id='HtYmk'><dt id='HtYmk'><q id='HtYmk'><span id='HtYmk'><b id='HtYmk'><form id='HtYmk'><ins id='HtYmk'></ins><ul id='HtYmk'></ul><sub id='HtYmk'></sub></form><legend id='HtYmk'></legend><bdo id='HtYmk'><pre id='HtYmk'><center id='HtYmk'></center></pre></bdo></b><th id='HtYmk'></th></span></q></dt></tr></i><div id='HtYmk'><tfoot id='HtYmk'></tfoot><dl id='HtYmk'><fieldset id='HtYmk'></fieldset></dl></div>

                  本文介绍了仅在命名空间内公开类的 C# 访问修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 java 中,您有包级别的保护,可确保类仅在包中可用.

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

                  C# 中的命名空间或多或少类似于包.但是 C# 没有用于保护命名空间中的类的保护级别.

                  Namespaces in C# act more or less like packages. But C# does not have a protection level for protecting classes within a namespace.

                  这有什么具体原因吗?

                  推荐答案

                  没有这样的访问修饰符:最接近的修饰符是internal,但是保护单元是类所在的程序集,而不是它的命名空间.

                  There is no such access modifier: the closest modifier is internal, but the unit of protection is the assembly in which the class resides, not its namespace.

                  有人可能会争辩说,使用 internal 可以实现类似级别的控制,因为这两种限制都可以防止外人访问您的库的实现细节.唯一对它有影响的人是你,图书馆的作者,你完全可以控制要公开什么,要隐藏什么.从本质上讲,这意味着如果您不想在其命名空间之外使用某个类,只需避免使用它即可;如果类是internal,其他人也不能使用该类.

                  One could argue that it is possible to achieve similar level of control using internal, because both kinds of restriction keep outsiders from accessing the implementation details of your library. The only person to whom it makes a difference is you, the writer of the library, and you are in full control of what to expose and what to hide anyway. Essentially, it means that if you do not want to use a class outside its namespace, simply refrain from using it; if the class is internal, nobody else will be able to use that class either.

                  这篇关于仅在命名空间内公开类的 C# 访问修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  IBM.Data.DB2.Core connection problems(IBM.Data.DB2.Core 连接问题)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  Datetime field overflow with IBM Data Server Client v9.7fp5(IBM Data Server Client v9.7fp5 的日期时间字段溢出)
                  Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                  <i id='VKuDq'><tr id='VKuDq'><dt id='VKuDq'><q id='VKuDq'><span id='VKuDq'><b id='VKuDq'><form id='VKuDq'><ins id='VKuDq'></ins><ul id='VKuDq'></ul><sub id='VKuDq'></sub></form><legend id='VKuDq'></legend><bdo id='VKuDq'><pre id='VKuDq'><center id='VKuDq'></center></pre></bdo></b><th id='VKuDq'></th></span></q></dt></tr></i><div id='VKuDq'><tfoot id='VKuDq'></tfoot><dl id='VKuDq'><fieldset id='VKuDq'></fieldset></dl></div>
                  <tfoot id='VKuDq'></tfoot>

                    <bdo id='VKuDq'></bdo><ul id='VKuDq'></ul>

                  • <legend id='VKuDq'><style id='VKuDq'><dir id='VKuDq'><q id='VKuDq'></q></dir></style></legend>
                        <tbody id='VKuDq'></tbody>

                          <small id='VKuDq'></small><noframes id='VKuDq'>