Handle Union of List in C# with duplicates
- by user320587
Hi,
I am trying to understand how to handle union or merge of two lists that can have duplicates.
For example, List1 has { A, B, C} and List2 has { B, C, D }.
I tried to use the Union operation and got a new list with values (A, B, C, D}. However, I need the B & C values from the second list, not first one.
Is there a way to specify the union method, which duplicate value to use.
The code I am using now is
var newList = List1.Union<Object>(List2).ToList();
Thanks for any help.
Javid