Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge List<T> of the same Type

Tags:

c#

list

I got 2 Lists whose defs are :

List<Type> filteredTypes = new List<Type>();
List<Type> interfaceTypes = new List<Type>();

When my Lists are populated I'd like to get a single loop on both of them and my idea is to merge them before "looping" so I don't have to use a LINQ (don't like it...-_-) I checked the online doc and I think I gotta do :

filteredTypes.Concat(interfaceTypes);

I debugged as deeply as I could and my Lists are the same after the instruction... What am I missing ?

like image 599
Guillaume Slashy Avatar asked Dec 10 '22 04:12

Guillaume Slashy


1 Answers

The concat function returns a new collection, it doesn't add to the existing one.

var allTypes = filteredTypes.Concat(interfaceTypes);
like image 62
DaveShaw Avatar answered Dec 24 '22 22:12

DaveShaw