I have the following variable:
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
*/
An example:
Comment comment = moderatedComments[1][0].First();
// Repository 1
// Moderation operation 0
// First moderated comment for that repository and operation
I want to merge all three dimensions into one ( IEnumerable<Comment>
) containing all the moderated comments, regardless of the repository or moderation operation.
How can this be accomplished with LINQ?
Do it like this, please:
IEnumerable<Comment>[][] moderatedComments;
var merged = moderatedComments.SelectMany(x => x).SelectMany( x => x );
// merged is IEnumerable<Comment>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.