-3

I have 2 sorted lists of strings with repetitions

ListA = {a,a,b,c,c,d,e,f}
ListB = {a,a,a,c,e,f,g,g}

If i pass this to some program like Diff or Compare It!, i would get the following output
enter image description here

What i would like to have is the following lists

Listcommon = {a,a,c,e,f} (Common in both)

ListAdiff = {b,c,d} 

ListBdiff = {a,g,g} 

Sorry if i was not clear before but this is what i want to do..Is there any in built classes in C# which can do this? Or any other piece of code?

uzair_syed
  • 313
  • 3
  • 16
  • 1
    possible duplicate of [Check for any element that exists in two collections](http://stackoverflow.com/questions/12584179/check-for-any-element-that-exists-in-two-collections) – default Jul 09 '15 at 07:01

1 Answers1

2

This has been asked many times, but you're looking for:

In both lists:

listA.Intersect(listB);

In A but not b:

listA.Except(listB);
Rob
  • 26,989
  • 16
  • 82
  • 98