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
Post a Comment