.NET Multiple Namespaces for single class

前端 未结 3 1638
一生所求
一生所求 2020-12-18 19:02

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

To clarify: We have a class library (let say root namespace is classLib1),

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 19:39

    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.

提交回复
热议问题