在C#中嵌套命名 [英] nested namespace in C#
本文介绍了在C#中嵌套命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要包含一个命名空间,如在一组静态字符串属性:
I need to contain a set of static string properties under a namespace such as:
namespace1 N1 {
namespace N2 {
public const string A = "a";
}
public const string B = "c";
namespace N3 {
public const string A = "a";
}
}
是否有可能在C#中嵌套的命名空间?什么是更好的设计方法?使用静态类或在这种情况下使用名称空间?
Is it possible to have nested namespaces in C#? What is the better design approach? Using static classes or using namespaces in this case?
感谢
推荐答案
是,也可以具有在C#嵌套命名空间。
Yes, it is possible to have nested namespaces in C#.
然而,这是不可能直接具有恒定一个命名空间内。你必须把它变成一个类。
However, it is impossible to have a constant directly inside a namespace. You have to put it into a class.
这篇关于在C#中嵌套命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文