c# - Comparison and re-structuring of 3 lists into a single list? -


so have following:

class item {     string name;     bool isselected; } 

and have 3 lists:

list<item> list1; list<item> list2; list<item> list3; 

my objective translate above single collection similar 'item' objects grouped (similar = objects have same 'name').

so want:

list<itemcontainer> resultantlist; 

where:

class itemcontainer {     string name;     ilist<item> items;  //items same 'name' (potentially) } 

notes:

  • the lists can have different number of items.
  • an 'item' object can belong 1 list. it's can have different objects same 'name' in different lists.
  • if no other object same 'name' found, still need included in resulting list.

what concise , clearest way of implementing this?

note: performance not concern.

thanks help.

you can try groupby,

var groupyname = list1.concat(list2).concat(list3).groupby(i => i.name); 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -