【发布时间】:2015-07-14 18:24:36
【问题描述】:
给定一个列表:
private List<KeyValuePair<string, string>> KV_List = new List<KeyValuePair<string, string>>();
void initList()
{
KV_List.Add(new KeyValuePair<string, string>("qwer", "asdf"));
KV_List.Add(new KeyValuePair<string, string>("qwer", "ghjk"));
KV_List.Add(new KeyValuePair<string, string>("zxcv", "asdf"));
KV_List.Add(new KeyValuePair<string, string>("hjkl", "uiop"));
}
(注意:键“qwer”有多个值,值“asdf”有多个键。)
1) 有没有比仅在 KeyValuePair 列表上执行 foreach 更好的方法来返回所有键的列表?
2) 同样,有没有比使用 foreach 更好的方法来返回给定键的所有值的列表?
3) 然后,返回给定值的键列表怎么样?
谢谢...
【问题讨论】:
-
你能使用像this这样的多图吗?
标签: c# list keyvaluepair