<i id='pzUVE'><tr id='pzUVE'><dt id='pzUVE'><q id='pzUVE'><span id='pzUVE'><b id='pzUVE'><form id='pzUVE'><ins id='pzUVE'></ins><ul id='pzUVE'></ul><sub id='pzUVE'></sub></form><legend id='pzUVE'></legend><bdo id='pzUVE'><pre id='pzUVE'><center id='pzUVE'></center></pre></bdo></b><th id='pzUVE'></th></span></q></dt></tr></i><div id='pzUVE'><tfoot id='pzUVE'></tfoot><dl id='pzUVE'><fieldset id='pzUVE'></fieldset></dl></div>
    <bdo id='pzUVE'></bdo><ul id='pzUVE'></ul>
  1. <tfoot id='pzUVE'></tfoot>

    1. <legend id='pzUVE'><style id='pzUVE'><dir id='pzUVE'><q id='pzUVE'></q></dir></style></legend>

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

      将自定义代码放在系统命名空间中

      Placing custom code in a System namespace(将自定义代码放在系统命名空间中)

        <legend id='jPmBC'><style id='jPmBC'><dir id='jPmBC'><q id='jPmBC'></q></dir></style></legend>
        1. <small id='jPmBC'></small><noframes id='jPmBC'>

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

              • 本文介绍了将自定义代码放在系统命名空间中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否有任何最佳实践表明不应将自定义代码放置在 System 命名空间中?System 及其子项是否应保留给 Microsoft 代码?

                Are there any best-practices that state custom code shouldn't be placed in a System namespace? Should System and its children be reserved for Microsoft code?

                我问是因为我正在编写一个将在许多项目中使用的类库,我想通过将它放在 System.InteropServices 中来保持一致性(因为它处理 P/调用).

                I ask because I'm writing a class library that will be used across many projects and I'd like to keep things consistent by placing it in System.InteropServices (since it deals with P/Invoke).

                推荐答案

                这不是一个好主意,因为它破坏了命名空间的主要好处之一:防止名称冲突.如果较新版本的框架在该命名空间中引入了同名类型怎么办?

                It's not a good idea because it defeats one of the primary benefits of namespaces: preventing name clashes. What if a newer version of the framework introduced an identically named type in that namespace?

                这对于 System 命名空间尤其不利,因为它们是通过 using 指令导入到许多其他代码段中,并且在这些命名空间中引入自定义类型会污染其他命名空间的命名范围带有意外标识符的源文件.

                This is particularly bad for System namespaces since they are imported in many other pieces of code with using directives and introducing custom types in those namespaces pollutes the naming scope of other source files with unexpected identifiers.

                要对您的自定义互操作相关类型进行分类,您可以创建一个新的命名空间,例如 MyProduct.InteropServices.

                To categorize your custom interop related types, you can create a new namespace like MyProduct.InteropServices.

                这篇关于将自定义代码放在系统命名空间中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 结合使用)

                  • <bdo id='V2lvJ'></bdo><ul id='V2lvJ'></ul>
                  • <tfoot id='V2lvJ'></tfoot>
                      <tbody id='V2lvJ'></tbody>
                    <legend id='V2lvJ'><style id='V2lvJ'><dir id='V2lvJ'><q id='V2lvJ'></q></dir></style></legend>

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

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