Using LINQ to filter rows of a matrix based on inclusion in an array
Posted
by Bob Feng
on Stack Overflow
See other posts from Stack Overflow
or by Bob Feng
Published on 2010-04-14T14:35:56Z
Indexed on
2010/04/15
23:13 UTC
Read the original article
Hit count: 148
LINQ
I have a matrix, IEnumerable<IEnumerable<int>>
matrix, for example:
{ {10,23,16,20,2,4}, {22,13,1,33,21,11 }, {7,19,31,12,6,22}, ... }
and another array:
int[] arr={ 10, 23, 16, 20}
I want to filter the matrix on the condition that I group all rows of the matrix which contain the same number of elements from arr.
That is to say the first row in the matrix {10,23,16,20,2,4}
has 4 numbers from arr, this array should be grouped with the rest of the rows with 4 numbers from arr.
better to use linq, thank you very much!
© Stack Overflow or respective owner