I'm currently trying to build up one array by injecting multiple nested arrays into a for loop. This is not currently working but i cant figure out what i'm doing wrong.
Here is my current code :
// initialise an empty array
var x = new List<Model>();
// initialise an empty array to use in the loop
var mergedX = new List<Model>();
// Build up the array using the loop
foreach (var y in ys) {
if (y.nestedArray != null) {
mergedX = x.Concat(y.nestedArray).ToList();
}
}
// Return the built up array
return mergedX;
What am I doing wrong/is there a better way to achieve this?
Thanks