c# - 使用 LINQ 连接列表

标签 c#

是否可以连接 List<List<T>>进入 List<T>以一种并不可怕的方式进行单一操作,即:

List<List<int>> listOfLists = new List<List<int>>();
List<int> concatenatedList = listOfLists.Something...

?

最佳答案

listOfLists.SelectMany( l => l );

整行:

List<int> concatenatedList = listOfLists.SelectMany( l => l ).ToList();

关于c# - 使用 LINQ 连接列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4734556/

相关文章:

c# - WPF 内存泄漏导致 System.Windows.Forms.Integration.AvalonAdapter

c# - FreeLibrary 无限期地返回 true

c# - App.Exit 不立即退出?

c# - C# 中的 mysqldump.exe 和 mysql.exe 访问

c# - 在 C# 中删除 flowlayoutpanel 中的所有控件

javascript - Unity C# 如何正确加载托管 DLL?

c# - Excel 工作表修改当前工作表 C#

c# - 使用 Razor 页面返回 XML?

c# - Exception 的 .ToString() 和 .Message 有什么区别?

c# - Dictionary<myField, myObject> 其中 myField 是 myObject 的成员