我正在寻找一个返回构造字典的类。我不确定如何编写构造函数以返回字典,如何初始化与键配对的多个字符串值,我发现的唯一示例是非常粗略的草稿。这是一个粗略的例子:
namespace MyApp.Helpers
{
public enum HouseSize
{
Big,
Medium,
Small
}
class Houses
{
public static Dictionary<HouseSize, string> _dictionaryOfHouses;
public static Dictionary<HouseSize, string> Houses
{
get
{
if (_dictionaryOfHouses == null)
LoadHouses();
return _dictionaryOfHouses;
}
}
}
private static void LoadHouses()
{
_dictionaryOfHouses = new Dictionary<HouseSize, string>;
_dictionaryOfHouses.Add(HouseSize.Big, /*Add String Properties Here like Red, 2 Floor, Built in 1975*/);
_dictionaryOfHouses.Add(HouseSize.Small, /*Add String Properties Here like Blue, 1 Floor, Built in 1980*/);
}
}