Handle Union of List in C# with duplicates

Posted by user320587 on Stack Overflow See other posts from Stack Overflow or by user320587
Published on 2010-04-20T15:12:11Z Indexed on 2010/04/20 15:23 UTC
Read the original article Hit count: 888

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about list

Related posts about merge