给定一个列表:
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)那么,如何返回给定值的所有关键字的列表?
谢谢...