Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert dictionary values to list using linq

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(); 

Thanks,

like image 961
Chris_web Avatar asked Jul 29 '13 13:07

Chris_web


1 Answers

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(); 
like image 143
Dustin Kingen Avatar answered Oct 12 '22 08:10

Dustin Kingen