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.
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.
– johnc Sep 19 '08 at 7:22 1 Actually, due to deferred execution, using Concat would likely be faster because it avoids object allocation - Concat doesn't copy anything, it just creates links between the lists so when enumerating and you reach the end of one it transparently takes you to the start of the next! – Greg Beech Sep 19 '08 at 7:32 makes sense, thanks – johnc Oct 2 '08 at 7:09.
The big difference is that AddRange mutates that list against which it is called whereas Concat creates a new List. Hence they have different uses. Also Concat is an extension method that applies to any IEnumerable and returns an IEnumerable you need a .ToList() to result in a new List.
If you want to extend the content of an existing list use AddRange. If you are creating a new list from two IEnumerable sources then use Concat with .ToList. This has the quality that it does not mutate either of sources.
If you only ever need to enumerate the contents of two Lists (or any other IEnumerable) then simply use Concat each time, this has the advantage of not actually allocating new memory to hold the unified list.
A generic List does not have a Concat function. I assume it is a LINQ extenstion function then, which will likely operate on an IEnumerable. Hence going for AddRange should be a little better.
I think it is now you mention it – johnc Sep 19 '08 at 7:20 AddRange has a completely different purpose. It mutates the list. If that's not what you want, Concat is better.
Also, Concat is (probably) O(1) in both time and space. – Brian Jul 1 '10 at 16:20.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.