c#编程dictionary中如何通过value 来获取相应的key
2 回答
12345678_0001
TA贡献1802条经验 获得超5个赞
Demo:
var dic = new Dictionary<string, int>() { {"a",1}, {"b",2}, {"c",3}, {"d",1} };foreach (var item in dic) { if (item.Value == 1) { Console.WriteLine(item.Key); } }
阿波罗的战车
TA贡献1862条经验 获得超6个赞
Dictionary<string,string> dic =newDictionary<string,string>() {{"1","one"},};var key_by_value = dic.Where(p => p.Value=="one").Select(p => p.Key);foreach(var key in key_by_value ){....}
- 2 回答
- 0 关注
- 1572 浏览
添加回答
举报
0/150
提交
取消