嵌套的命名空间 [英] Nested namespaces
本文介绍了嵌套的命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的事情:
<预类=郎CSHARP prettyprint-覆盖>
命名空间N1
{
命名空间N2
{
类Foo {}
}
}
在其他文件中我写的:
<预类=郎CSHARP prettyprint-覆盖>
使用N1;
为什么我现在不能输入类似:
<预类=郎CSHARP prettyprint-覆盖>
n2.foo smthing;
和如何使这样的不可能性?
解决方案
使用命名空间的别名:使用N2 = N1.N2
;
...
n2.foo的东西;
什么是类的名字前应该是一个完整的名字空间(与/或其他类名(S ),用于嵌套类型)。截短空间将无法工作。
I've got something like this:
namespace n1
{
namespace n2
{
class foo{}
}
}
In other file I write:
using n1;
Why I can't type now something like:
n2.foo smthing;
And how to make something like this possibile?
解决方案
Use namespace aliases:
using n2 = n1.n2;
...
n2.foo something;
What is before the class name should be a complete name space (with/or other class name(s) for nested types). A truncated namespace will not work.
这篇关于嵌套的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文