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#中的命名空间冲突


基础教程推荐
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01