.Net命名空间问题

UpT*_*eek -1 .net c# namespaces visual-studio

我有两个名称空间:

1)Foo.Bar

2)Another.Foo.Bar

从命名空间2中的类,如何引用命名空间1中的类?使用Foo.Bar离开你的命名空间2仍然...

我希望这个相当清楚!

谢谢.

Ree*_*sey 9

您需要使用全局限定符.

只需添加:

using GFooBar = global::Foo.Bar;
Run Code Online (Sandbox Code Playgroud)

然后将其称为:

GFooBar.MyClass = new GFooBar.MyClass();
Run Code Online (Sandbox Code Playgroud)

要么

global::Foo.Bar.MyClass = new global::Foo.Bar.MyClass();
Run Code Online (Sandbox Code Playgroud)