Chr*_*web 29 c# linq dictionary list
下面的代码给出了'lambda表达式的评估在调试器中无效'.请从下面建议我做错的地方 -
List<MyFieldClass> lstFiedls;
lstFiedls = objDictionary.Select(item => item.Value).ToList();
Run Code Online (Sandbox Code Playgroud)
谢谢,
Dus*_*gen 65
您不需要使用Linq来获取值.它Dictionary(TKey, TValue)有一个包含值的属性Dictionary(TKey, TValue).Values:
var fields = objDictionary.Values.ToList();
Run Code Online (Sandbox Code Playgroud)
只需尝试将字典的值转换为带有ToList()的列表,您将收到编译器错误:
Dictionary<int, int> dict = new Dictionary<int, int>();
var result = dict.Values.ToList();
Run Code Online (Sandbox Code Playgroud)
除非您在文件中包含"using System.Linq".
| 归档时间: |
|
| 查看次数: |
47091 次 |
| 最近记录: |