convert Decimal array to Double array

2019-03-23 10:25发布

What's an efficient and hopefully elegant incantation to convert decimal[] to double[]? I'm working with some fairly large arrays.

2条回答
太酷不给撩
2楼-- · 2019-03-23 10:52

You also can use and extension classes similar to this one

public static class ArrayExtension
{

   public static double[] ToDouble(this float[] arr) => 
                                    Array.ConvertAll(arr, x => (double)x);

}

Then:

double[] doubleArr = decimalArr.ToDouble();
查看更多
你好瞎i
3楼-- · 2019-03-23 11:08
double[] doubleArray = Array.ConvertAll(decimalArray, x => (double)x);
查看更多
登录 后发表回答