Your question isn't very clear - what kind of input do you have and what output do you want to get as the result?
Based on your example, it seems that you simply want to get all elements of 2D array as a single list and then do some operation with the elements. To convert 2D array to a single IEnumerable
containing all the elements, you can write:
IEnumerable<T> AsEnumerable(this T[,] arr) {
for(int i = 0; i < arr.GetLength(0); i++)
for(int j = 0; j < arr.GetLength(1); j++)
yield return arr[i, j];
}
And then write for example:
int[,] data = // get data somwhere
// After 'AsEnumerable' you can use all standard LINQ operations
var res = data.AsEnumerable().OrderBy(n => n).Reverse();
Tomas Petricek
2010-06-19 17:44:52