Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的程序中声明了一个列表
List<List<object>> result = new List<List<object>>();
如何将数据打印result到控制台?
result
foreach (var sublist in result) { foreach (var obj in sublist) { Console.WriteLine(obj); } }
或者,如果您想使用 linq:
foreach (var obj in result.SelectMany(l => l.Select(o => o))) { Console.WriteLine(obj); }
如果您使用的是 linq,请尝试
SelectMany扩展
查看以下链接以获取示例
Linq SelectMany 运算符