I have two lists
List<string> list1 as new List<string>();
and
List<string> list2 as new List<string>();
What I want to do is create a third list that is a list of differences.
Example: list1 contains (Test1, Test2, Test3, Test4) list2 contains (Test1, Test3)
I would want my new list to contain (Test 2, Test4)
I tried using
newlist = list1.Except(list2).ToList();
and for the above example it works fine.
Example 2: list 1 contains (Test1, Test1, Test2, Test2) list 2 is empty
I want my newlist to contain everything (Test1, Test1, Test2, Test2)
If I use the same Except method I was using above I get in my newlist (Test1, Test2)
Is there a way I can include the duplicates?
One more final example so it is hopefully clear on what I am looking for list1 contains (Test1, Test2, Test2, Test3, Test4) list2 contains (Test1, Test2, Test5, Test6)
I would want my newlist to contain (Test2, Test3, Test4, Test5, Test6)
One more thing is that list1 and list2 are in no particular order and newlist does not need to be in any particular order either.