How to find out different elements in two arrays in C#?

arrays, c#

Solution

The easiest way is using LINQ, and in particular the methods `Distinct` and `Except`.

To remove duplicates from `array1`:

 var withoutDupes = array1.Distinct().ToArray();

To see what elements were added in `array2` using `array1` as reference:

 var added = array2.Except(array1).ToArray();

To see what elements were removed in `array2` using `array1` as reference:

 var removed = array1.Except(array2).ToArray();

Problem

I have array in c# ``` int array1 = new int[]{1,2,3,3,4,5}; ``` and I have two problems: - I do not know how delete duplicate elements in array. - When I compare array1 to array3 `{1,2,3,4,5,6,7,8,9,10}`, how many elements disappear and what numbers are they? I have no idea to accomplish this!

Original source