开发者

Namespace conflict in 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?

Namespace conflict in 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:

Namespace conflict in 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;

Some MSDN documentation on it: http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx


For more convenience, you can give it an alias, too:

using GSystem = global::System;

Will allow you to refer to the global System namespace as GSystem or whatever else you would like to call it.


yes

global::System

Strange though that you are getting a conflict with system.

Nothing should declare that namespace except system itself....


You can use global

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜