Compare list to list with a twist

I want to compare two lists of different lengths and / or the same length. The first list is considered the original list. The second list is an updated list. The second list may be the same, but ordered in different ways.

I would like to track additions and subtractions from the list. If something has been deleted, it can be added to the remote collection and vice versa.

Below is an example of each input list

Original List Updated List ============= ============ Jim Tom Tom Mike Mike Harry Sue Sue Kim Roger Roger 

This is the desired result:

 Addition List Subtraction List ============= ================ Harry Jim Kim 

If you have any ideas, I would be happy to hear them!

+4
source share
1 answer

Use LINQ.

 var diff1 = List1.Except(List2); var diff2 = List2.Except(List1); 
+8
source

Source: https://habr.com/ru/post/1393312/


All Articles