-2

I have an array which has another array inside of it and I want to merge all of them into one array using linq.

enter image description here

uzay95
  • 16,052
  • 31
  • 116
  • 182

2 Answers2

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