I have an array which has another array inside of it and I want to merge all of them into one array using linq.
Asked
Active
Viewed 80 times
2 Answers
1
You want to flatten your multidimensional array, use SelectMany
:
var mergedValues = values.SelectMany(subArray => subArray)
.ToArray();
you can see other examples of flattening different structures here

Community
- 1
- 1

Ilya Ivanov
- 23,148
- 4
- 64
- 90
1
You are looking for Enumerable.SelectMany
:
var flattened = a.SelectMany(row => row).ToArray();

Jon
- 428,835
- 81
- 738
- 806