[Solved] Datatable to dictionary [closed]
Based on the additional information, the problem is that you are not passing the right arguments to ToDictionary. It takes two lambdas, not a lambda and a List<>. Here’s the first step to fixed code: dt.AsEnumerable().ToDictionary( dtRow => dtRow.Field<Int64>(“CodeVal_1”), dtRow => new List<string> { dtRow.Field<string>(“CodeVal_2”), dtRow.Field<string>(“CountryCode”) } ); EDIT: fixed using wrong version of ToDictionary. … Read more