I have 2 lists in C#
List<int> list1 = new List<int> { 78, 92, 100, 37, 81 };
List<int> list2 = new List<int> { 3, 92, 1, 37 };
The expected result should be
{ 3, 78, 100, 1, 81 }
Please note! Duplicates: 92
and 37
doesn't appear anymore in the new list.
The new list should have non duplicated elements from both lists.
Each list cannot have duplicated values. Ideally i would like to extend it to an object.
I can do it iterating manually both lists finding and removing duplicates.
My question is : Is there a more elegant and compact way to do in with .NET C# ?