Namespace conflict in C#(C#中的命名空间冲突)
问题描述
在我的程序命名空间中有一个 System
命名空间.结果,我无法从我的内部看到标准的 System
命名空间.我该如何解决这个问题?
There is a System
namespace inside my program's namespace. And as a result I can't see the standard System
namespace from within mine. How can I resolve this problem?
例如,在 C++ 中,有一个 ::
运算符将我转移"出我的命名空间,因此我可以看到与当前命名空间同名的外部命名空间:
For example in C++ there is the ::
operator which 'shifts' me out of my namespace, so I can see external namespaces with the same name as my current namespace:
C#中有类似的运算符吗?
Is there a similar operator in C#?
推荐答案
您需要使用 global
关键字.这迫使命名空间解析从最顶部开始.它主要用于生成的代码中,以双重确保引用了正确的命名空间.
You need to use the global
keyword. That forces the namespace resolution to start at the very top. It's mostly used in generated code to be doubly sure the right namespace is referenced.
global::System.Foo.Bar;
关于它的一些 MSDN 文档:http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx
Some MSDN documentation on it: http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx
这篇关于C#中的命名空间冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C#中的命名空间冲突


- C#MongoDB使用Builders查找派生对象 2022-09-04
- C# 中多线程网络服务器的模式 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01