You might be confusing multidimensional arrays and jagged arrays, particularly here:
return (float[,])al.ToArray(typeof(float[][]));
There's a big difference between a
float[,]
and a
float[][]
- see
here[
^] and
here[
^] for the differences.
The
ArrayList
of
ArrayList
s is more akin to a jagged array than a multidimensional one. The
ToArray
is most likely failing because it's trying to convert the elements in
al
to either a
float
,
float[]
or part of a
float[,]
and it can't because they're more
ArrayList
s instead of something "float-ish". I'm betting that you'll have to manually convert the
ArrayList
to the
float[,]
instead of using
ToArray
to get your method to work correctly.
Also,
List<>
s are preferred over
ArrayList
s nowadays. If you changed that part I think it'd be easier to see what I'm talking about because you have a
List<List<float>>
and it's clear that the outer list holds more lists and the inner list holds the actual floats. With
ArrayList
s the types are lost so it's not as clear what the things in the collection are.