Michael Howes wrote:
>
I have many double[] that each have a few thousand numbers in them.
I need to concatenate groups of these double arrays into a new set of
double[].
I don't know the total # of points.
Of course you do. Each array has a length, you only have to add them.
I thought it would be fairly easy to add these different double arrays
to different ArrayLists and then use ToArray to get all the numbers back
in one array. Sort of a cheap concatenate so I don't need to loop
through all the points or keep newing larger arrays
Any method that could do what you are trying to accomplish, would do
exactly what you are trying to avoid doing yourself.
when I call ToArray
(double[])yData.ToArray(typeof(double))
I get an exception; "At least one element in the source array could
not be cast down to the destination array type."
Umm..they were all valid doubles in arrays of doubles before being
added to the ArrayList
You can't convert a double array into a double. The ToArray method will
produce an array with the same number of items as the ArrayList has, it
won't expand any arrays in the ArrayList.
Just create an array with the length of the sum of all the arrays that
you want to put in it, then use the CopyTo method to copy the data from
each array into the new array.
--
Göran Andersson
_____
http://www.guffa.com