【发布时间】:2010-11-14 12:46:23
【问题描述】:
这个问题令人困惑,但如以下代码所述,它更清楚:
List<List<T>> listOfList;
// add three lists of List<T> to listOfList, for example
/* listOfList = new {
{ 1, 2, 3}, // list 1 of 1, 3, and 3
{ 4, 5, 6}, // list 2
{ 7, 8, 9} // list 3
};
*/
List<T> list = null;
// how to merger all the items in listOfList to list?
// { 1, 2, 3, 4, 5, 6, 7, 8, 9 } // one list
// list = ???
不确定是否可以使用 C# LINQ 或 Lambda?
基本上,我如何连接或“展平”列表列表?
【问题讨论】: