c# - How to group a list of lists into repeated items -
i have c# problem. have list of object of type item. need group sub item lists of of these both "subitemcode", can repeated between items, , "subitemgroup", can repeated. have idea i'll want linq grouping, unsure group by?
class item { string itemcode; list<subitem> subitems; } class subitem { string subitemcode; string subitemgroup; list<string> validparentitems; }
so, idea like
var results = item in itemlist subitem in item.subitems group subitem ???????
so, pointer @ how can group items?
note: before says, not homework. don't see point in tearing hair out on when getting on more productive. no point re-inventing wheel right?
try this:
var results = itemlist.selectmany(i => i.subitems).groupby(i => i.subitemgroup);
Comments
Post a Comment