If I have two lists of type string (or any other type), what is a quick way of joining the two lists?
The order should stay the same. Duplicates should be removed (though every item in both links are unique). I didn’t find much on this when googling and didn’t want to implement any .NET interfaces for speed of delivery.
You could try:
MSDN page for
AddRangeThis preserves the order of the lists, but it doesn’t remove any duplicates (which
Unionwould do).This does change list
a. If you wanted to preserve the original lists then you should useConcat(as pointed out in the other answers):This returns an
IEnumerableas long asais not null.