如何解决两个命名空间之间的冲突?

发布于 2024-12-27 05:20:33 字数 266 浏览 1 评论 0原文

如果我有两个类的命名空间。我想使用一个命名空间中的类,并且我有 Resharpner 工具。即使我选择 Font 类的完整限定名称,它也会使用系统命名空间中的 Font。如何使用标签以及是否会

使用System.Windows.Forms删除调试功能;

使用 Cy.GlobalSettings.ChartSettings;

但有问题

当前命名空间是 Cy.GlobalSettings.ChartSettingsUC;

字体类别有冲突?

If I have namespace with two classes. I want to use class from one namespace and I have Resharpner tool. Even I select full qualifies name of my Font class it will use Font from System namespace. How to use label and will it removed debugging capability

using System.Windows.Forms;

using Cy.GlobalSettings.ChartSettings;

but have problem

current namespace is Cy.GlobalSettings.ChartSettingsUC;

Font class has a confilct?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

檐上三寸雪 2025-01-03 05:20:33

如果两个引用的命名空间中的类名相同,则可以重命名类。如果两个命名空间都有一个名为 Font 的类,您可以为命名空间或类型创建别名:

using System.Windows.Forms;
using Cy.GlobalSettings.ChartSettings;
using CyFont = Cy.GlobalSettings.ChartSettings.Font // This is the full name of the Font class which is causing the conflict. 


Font y; // class from System.Windows.Forms
CyFont x; // class from Cy.GlobalSettings.ChartSettings

此后,您可以在代码中同时使用 Font 和 CyFont,而不会发生冲突。

using 指令(C# 参考)
http://msdn.microsoft.com/en- us/library/sf0df423(v=vs.80).aspx

完全限定名称也应该有效。

You can rename classes if the class name is the same in both referenced namespace. If both namespace have a class called Font you can create an alias for a namespace or a type:

using System.Windows.Forms;
using Cy.GlobalSettings.ChartSettings;
using CyFont = Cy.GlobalSettings.ChartSettings.Font // This is the full name of the Font class which is causing the conflict. 


Font y; // class from System.Windows.Forms
CyFont x; // class from Cy.GlobalSettings.ChartSettings

After this you can use both Font and CyFont in your code without conflicts.

using Directive (C# Reference)
http://msdn.microsoft.com/en-us/library/sf0df423(v=vs.80).aspx

Fully qualified name should work as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文