使用嵌套类对常量进行分组有什么问题?
像这样:
public static class Constants
{
public static class CategoryA
{
public const string ValueX = "CatA_X";
public const string ValueY = "CatA_Y";
}
public static class CategoryB
{
public const string ValueX = "CatB_X";
public const string ValueY = "CatB_Y";
}
}
像这样使用:
Console.WriteLine(Constants.CategoryA.ValueY);
Console.WriteLine(Constants.CategoryB.ValueX);
您还可以使“常量”类部分...