Comparing two Lists and returning the distinct values and the differences
I have two lists:
List A { A, B, C, D }
List B { A, E, F, G }
I need to produce three lists:
One with the items only in list A
(B, C)
One with the items only in list B
(F, G)
One with the items in both
(A)
given that the lists are actually registry keys, there could be a huge
number of them so I can foresee a huge performance overhead if I chose to
use traditional ForEach or For(int i... methods.
I am not averse to these if they will do the job efficiently but I would
prefer to use Linq.
Has anyone got any ideas?
I dont care about identical records.
I have already created an IEquatable<> class that will compare the
elements, but it is how to use this to create my required outputs that I
am struggling with.
Thanks in advance.
by the by I am using VS2012 with .NET 4.5
No comments:
Post a Comment