在C#中的命名空间冲突 [英] Namespace conflict in C#

查看:312
本文介绍了在C#中的命名空间冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个系统命名空间我的程序的命名空间内。而作为一个结果,我不能看到的标准系统命名空间从我内。我怎样才能解决这个问题呢?

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#?

推荐答案

您需要使用全球关键字。这迫使空间分辨率,开始在最高层。 。这主要是在生成的代码中使用倍加确保正确的命名空间引用

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#中的命名空间冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆