C# Combine Two Lists With Overlapping Data

Viewed 1395

If I have 2 lists of strings

List<string> history = new List<string>(){ "AA", "BB", "CC", "AA" };
List<string> potentialNew = new List<string>(){ "CC", "AA", "DD", "EE", "FF", "AA"};

I need a way to combine the lists while preventing "overlap" and retaining the same ordering. So, in the example above, there would be a combined list that is:

AA, BB, CC, AA, DD, EE, FF, AA

In other words only DD, EE, FF, and AA are added to the history list.

I've been trying to figure this out for a few days now, and countless searches have yielded no solution. Any help would be greatly appreciated!

5 Answers
Related