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?
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:
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.