使用linq将字典值转换为列表 [英] Convert dictionary values to list using linq

查看:200
本文介绍了使用linq将字典值转换为列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码给出了评估lambda表达式在调试器中无效。
请建议我在下面做错什么 -

Following code giving me 'Evaluation of lambda expressions is not valid in the debugger'. Please suggest where I am doing wrong from below -

List<MyFieldClass> lstFiedls;
lstFiedls = objDictionary.Select(item => item.Value).ToList();

谢谢,

推荐答案

您不需要使用Linq来获取值。 字典(TKey,TValue)具有一个包含值的属性, 词典(TKey,TValue).Values

You don't need to use Linq to get the values. The Dictionary(TKey, TValue) has a property that holds the values, Dictionary(TKey, TValue).Values:

var fields = objDictionary.Values.ToList();

这篇关于使用linq将字典值转换为列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆