How to append enumerable collection to an existing list in C#

Well, something will have to loop… but in LINQ you could easily use the Concat and ToList extension methods:

var bigList = list1.Concat(list2).Concat(list3).ToList();

Note that this will create a new list rather than appending items to an existing list. If you want to add them to an existing list, List<T>.AddRange is probably what you’re after:

bigList.AddRange(list1);
bigList.AddRange(list2);
bigList.AddRange(list3);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)