.NET List<T> Concat vs AddRange

johnc picture johnc · Sep 19, 2008 · Viewed 45.1k times · Source

What is the difference between the AddRange and Concat functions on a generic List? Is one recommended over the other?

Answer

Greg Beech picture Greg Beech · Sep 19, 2008

They have totally different semantics.

AddRange modifies the list by adding the other items to it.

Concat returns a new sequence containing the list and the other items, without modifying the list.

Choose whichever one has the semantics you want.