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

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

      • <bdo id='X2cdy'></bdo><ul id='X2cdy'></ul>

      .NET 单个类的多个命名空间

      .NET Multiple Namespaces for single class(.NET 单个类的多个命名空间)
        1. <tfoot id='ZRjBs'></tfoot>
              <tbody id='ZRjBs'></tbody>

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

            • <legend id='ZRjBs'><style id='ZRjBs'><dir id='ZRjBs'><q id='ZRjBs'></q></dir></style></legend>
            • <small id='ZRjBs'></small><noframes id='ZRjBs'>

              1. <i id='ZRjBs'><tr id='ZRjBs'><dt id='ZRjBs'><q id='ZRjBs'><span id='ZRjBs'><b id='ZRjBs'><form id='ZRjBs'><ins id='ZRjBs'></ins><ul id='ZRjBs'></ul><sub id='ZRjBs'></sub></form><legend id='ZRjBs'></legend><bdo id='ZRjBs'><pre id='ZRjBs'><center id='ZRjBs'></center></pre></bdo></b><th id='ZRjBs'></th></span></q></dt></tr></i><div id='ZRjBs'><tfoot id='ZRjBs'></tfoot><dl id='ZRjBs'><fieldset id='ZRjBs'></fieldset></dl></div>
                本文介绍了.NET 单个类的多个命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                是否可以让一个类驻留在两个命名空间中,我该怎么做?

                Is it possible to have a single class reside within two name-spaces and how can I do this?

                澄清一下:我们有一个类库(假设根命名空间是 classLib1),它随着时间的推移而增长(更多类),我想在逻辑上将类分组到不同的命名空间中.然而,一些较旧的类需要被分组到这些新的命名空间中(例如 classLib1.section1),这样做会破坏使用这个类库的其他程序集中的遗留代码.所以我希望能够使用两个名称空间来引用一个类,直到我们可以逐步淘汰旧的.

                To clarify: We have a class library (let say root namespace is classLib1), which has grown over time (more classes) and I want to logically group classes into different namespaces. However some of the older classes need to be grouped into these new namespaces (e.g classLib1.section1) and doing so will break legacy code in other assemblys that use this class library. So I want to be able to refer to a class using both name-spaces until we can phase the old ones out.

                我找不到任何关于此的信息,这表明人们不想这样做是有原因的!?!

                I can't find any information on this, which suggests there is a reason that people would not want to do this!?!

                推荐答案

                不行,没有办法给单个类起两个名字(命名空间其实只是类名的一部分).

                No, there is no way to give a single class two names (the namespace is actually just a part of the class name).

                作为一种解决方法,您可以将类移动到它们的新位置,并在旧位置围绕它们创建薄包装(外观模式).当然,更好的解决方案是移动类并相应地修复遗留代码.

                As a workaround, you could move the classes to their new location, and create thin wrappers around them at the old location (Facade Pattern). A better solution, of course, would be to move the classes and fix the legacy code accordingly.

                这篇关于.NET 单个类的多个命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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='WyIrX'><tr id='WyIrX'><dt id='WyIrX'><q id='WyIrX'><span id='WyIrX'><b id='WyIrX'><form id='WyIrX'><ins id='WyIrX'></ins><ul id='WyIrX'></ul><sub id='WyIrX'></sub></form><legend id='WyIrX'></legend><bdo id='WyIrX'><pre id='WyIrX'><center id='WyIrX'></center></pre></bdo></b><th id='WyIrX'></th></span></q></dt></tr></i><div id='WyIrX'><tfoot id='WyIrX'></tfoot><dl id='WyIrX'><fieldset id='WyIrX'></fieldset></dl></div>
                  <bdo id='WyIrX'></bdo><ul id='WyIrX'></ul>
                  <legend id='WyIrX'><style id='WyIrX'><dir id='WyIrX'><q id='WyIrX'></q></dir></style></legend>

                    • <small id='WyIrX'></small><noframes id='WyIrX'>

                        <tbody id='WyIrX'></tbody>

                      1. <tfoot id='WyIrX'></tfoot>