c# - Error with returning a Dictionary list with Linq -
so have method returns categories listed in disctionary list, gives convert error @ select statement. first time work dictionary. missing?
this error get: "cannot implicitly convert type 'system.collections.generic.ienumerable' 'system.collections.generic.dictionary'. explicit conversion exists (are missing cast?)"
private task<dictionary<string, category>> getcategorieslist() { homecoming task.factory.startnew<dictionary<string, category>>(() => { var temp = _idataservice.categories; var tempcategorieslist = new dictionary<string, category>(); tempcategorieslist = (from categories in temp select categories.value.name); homecoming tempcategorieslist; }); }
this doesn't homecoming dictionary, returns ienumerable:
from categories in temp select categories.value.name
btw "temp" , "tempcategorieslist" awful variable names, , they're absolutely unnecessary. using todictionary() these 7 lines can reduced single one.
c# dictionary
No comments:
Post a Comment