C# list question -


what nice way make following action:

list<ienumerable<t>> listofenumerables = get...();  list<t> listofobjects = new list<t>();  // want 'listofobjects' contain every element every enumerable // in 'listofenumerables'. 

is there beautiful way make instead of following:

foreach (var enumerable in listofenumerables) {     listofobjects.addrange(enumerable); } 

thank you.

you can use linq:

list<t> listofobjects = listofenumerables.selectmany(s => s).tolist(); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -