公的な静的クラスを作成するか、内部定数を使用するか? 私は非常に大規模なアプリケーションに取り組んでおり、多くのplaces.Thisでのconst文字列の使用は、私が何をしたいのかpublic static classまたはconst
const string Thatch = "Thatch";
const string BrickAndTimberFrame= "Brick And Timber Frame";
const string OtherRoof = "Other";
etc......
etc......
を、ユーザーの選択を比較するために使用されて気づいたのですと、かなりコアにパブリック静的クラスを作成することですアプリケーション(コードを参照してください)。この理由は、値を変更/追加する必要があるのは1か所だけです。
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;
}
のようになりますなど
設定ファイル –