如何转换IEnumerable的KeyValuePair< x,y>到字典? [英] How to convert IEnumerable of KeyValuePair<x, y> to Dictionary?
本文介绍了如何转换IEnumerable的KeyValuePair< x,y>到字典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否精简,将 KeyValuePair< T,U>
的列表/ enumberable转换为字典< T,U>
?
Is there streamlined to convert list/enumberable of KeyValuePair<T, U>
to Dictionary<T, U>
?
Linq转换,.ToDictionary()扩展名不起作用。
Linq transformation, .ToDictionary() extension did not work.
推荐答案
.ToDictionary(kvp=>kvp.Key,kvp=>kvp.Value);
没有太多的工作。
这篇关于如何转换IEnumerable的KeyValuePair< x,y>到字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文