If you really want to create an uneven array as the result, you can use Array.ConvertAll twice:
var result = Array.ConvertAll(input, array => Array.ConvertAll(array, SomeFunction));
This is slightly more efficient than using Select / ToArray from LINQ, because it knows that it will convert the array to another array, so it can instantly create target arrays. Using Select , followed by ToArray , requires the gradual creation of the results, as if you put them in a List<T> , copying them when the buffer is exhausted, and then "right-aligning" the array at the end.
On the other hand, using LINQ (according to Daniel's answer) is likely to be more idiomatic these days ... and the performance difference will usually be negligible. I thought I would give it as another option :)
(Note that this creates new arrays, ignoring the existing OutputArray ... I assume that you can get rid of creating an existing OutputArray , although it may not be ...)
source share