我需要从字典中获取格式如下的数据:
private Dictionary<string, Dictionary<string, string>> MyDictionary = new Dictionary<string, Dictionary<string, string>>()
{
{"HEIGHT", new Dictionary<string,string>(){{"table", "TR_HEIGHT"}, {"prefix", "HEI"}}},
{"WEIGHT", new Dictionary<string,string>(){{"table", "TR_WEIGHT"}, {"prefix", "WIL"}}},
{"LENGTH", new Dictionary<string,string>(){{"table", "TR_LENGTH"}, {"prefix", "LEN"}}},
};
如果我插入&#34; HEIGHT&#34;我回来的前缀是&#34; HEI&#34;和表是&#34; TR_HEIGHT&#34;?
感谢&#39; S
答案 0 :(得分:2)
如果我插入“HEIGHT”,我可以返回前缀是“HEI”,表格是“TR HEIGHT”吗?
是
Dictionary<string, string> heightAttr = MyDictionary["HEIGHT"];
string table = heightAttr["table"]; // TR_HEIGHT
string prefix = heightAttr["prefix"]; // HEI