Namespace conflict in C#

后端 未结 4 630
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 15:05

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

相关标签:
4条回答
  • 2020-12-15 15:43

    You can use global

    0 讨论(0)
  • 2020-12-15 15:50

    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.

    0 讨论(0)
  • 2020-12-15 15:56

    yes

    global::System
    

    Strange though that you are getting a conflict with system.

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

    0 讨论(0)
  • 2020-12-15 16:04

    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

    0 讨论(0)
提交回复
热议问题