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#中的命名空间冲突
基础教程推荐
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
