I using Microsoft.Office.Interop.Excel
I get returned a 2D array of type object[,]
which contains double
for elements. Note that the index lower bound is 1
instead of the default 0
, but I can deal with that easily.
How can nicely convert the array into double[,]
using .NET 3.5. (by nicely I mean concise, or compact).
Note that
double[] values_2 = values.Cast<double>().ToArray();
does work, but it flattens by array into a 1D structure.
There are three ways to convert a String to double value in Java, Double. parseDouble() method, Double. valueOf() method and by using new Double() constructor and then storing the resulting object into a primitive double field, autoboxing in Java will convert a Double object to the double primitive in no time.
To convert a specified value to a double-precision floating-point number, use Convert. ToDouble() method. long[] val = { 340, -200}; Now convert it to Double.
object[,] src = new object[2, 3];
// Initialize src with test doubles.
src[0, 0] = 1.0;
src[0, 1] = 2.0;
src[0, 2] = 3.0;
src[1, 0] = 4.0;
src[1, 1] = 5.0;
src[1, 2] = 6.0;
double[,] dst = new double[src.GetLength(0), src.GetLength(1)];
Array.Copy(src, dst, src.Length);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With