List Join?? How can I do this?

S

shapper

Hello,

I have to lists: List<Role> A and List<Role> B. Role is an
enumeration.

I want to update list A as follows:
- The elements in list A are not changed.
- The elements in list B that do no exist in list A are added to list
A.

How can I do this?

Thanks,
Miguel
 
G

Göran Andersson

shapper said:
Hello,

I have to lists: List<Role> A and List<Role> B. Role is an
enumeration.

I want to update list A as follows:
- The elements in list A are not changed.
- The elements in list B that do no exist in list A are added to list
A.

How can I do this?

Thanks,
Miguel

Create a HashSet from list A. Loop through list B and each value that
doesn't exist in the HashSet you add to list A.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

List. How can I join them? 1
Find Ints in List ... 4
List. Check items 3
List. Add, Remove. 1
Sring[] to List<MyEnumeration> 5
List to EntityCollection 0
Add item at start 5
Join 3

Top