我正在寻找一个关于如何创建枚举类的最佳做法,而不是数字包含字符串值。 事情是这样的:类枚举类
public static class CustomerType
{
public static string Type1 = "Customer Type 1";
public static string Type2 = "Customer Type 2";
}
我会用这个类在整个应用程序设置为我需要CustomerType所有情况下的值。我不能使用Enum,因为这是遗留系统,像这样的值在任何地方都是硬编码的,我只是试图将它们集中在一个地方。
的问题是,在上面的例子中,我应该使用变量声明:
- 静态只读关键字
- const关键字
- 或只是静态
会是什么设置这些类和值的最佳实践?
请参阅http://stackoverflow.com/questions/3190870/const-string-vs-static-string-in-c-sharp。 – nneonneo 2013-02-19 07:01:00