Delete an item if it intersects between two ObservableCollection data types

How can I remove items if they intersect between two sources of the Observable-collection.

+1
source share
2 answers

Use Linq if you are not dealing with very large sets; but I guess not, as these are observable collections.

Considering

ObservableCollection<T> set1, ObservableCollection<T> set2 

get intersection like:

 var intersection = set1.Intersect(set2); 

Use a special comparison comparisons, if and if necessary.

0
source
 foreach(var p in recentPatients.Intersect(patients).ToList()) recentPatients.Remove(p); 
0
source

All Articles