-1
我应该创建一个公共静态类还是使用内部常量? 我工作的一个非常大的应用程序,并注意到在众多places.This使用常量字符串被用来比较的用户选择public static class或const
const string Thatch = "Thatch";
const string BrickAndTimberFrame= "Brick And Timber Frame";
const string OtherRoof = "Other";
etc......
etc......
我想要做的是在核心而建立公共静态类申请(见代码)。原因是我只需要在一个地方更改/添加一个值。然后
public static class RoofConstruction
{
public static String Thatch{ get { return "Thatch"; } }
public static String BrickAndTimberFrame { get { return "Brick And Timber Frame"; } }
etc....
etc....
}
比较功能看起来像这样
internal bool SlateTileOrConcreteRoof()
{
return RiskInformation.RoofConstruction.Value == RoofConstruction.Slate ||
RiskInformation.RoofConstruction == RoofConstruction.TileAndSlate ||
RiskInformation.RoofConstruction == RoofConstruction.Concrete;
}
请添加任何意见/改进等
更好地在配置文件中使用常量 –