繁体   English   中英

如何在一个数组中合并三维数组

[英]How to merge three dimensional array in one array

我有以下变量:

IEnumerable<Comment>[][] moderatedComments;
/**
* First dimension [] = The repository from where I fetched the comments (Could be more than one repository)
* Second dimension [][] = The moderation operation (There can only be two operations, so this dimension is always of size 2)
* Third dimension IEnumerable<Comment> = The moderated comments for that dimension
*/

一个例子:

Comment comment = moderatedComments[1][0].First();
// Repository 1
// Moderation operation 0
// First moderated comment for that repository and operation

我想将所有三个维度合并为一个( IEnumerable<Comment> ),其中包含所有审核的注释,而不管存储库或审核操作如何。

LINQ如何做到这一点?

这样做,请:

IEnumerable<Comment>[][] moderatedComments;
var merged = moderatedComments.SelectMany(x => x).SelectMany( x => x );
// merged is IEnumerable<Comment>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM