开发者

convert Decimal array to Double array

开发者 https://www.devze.com 2023-01-24 19:03 出处:网络
What\'s an efficient and hopefully elegant incantation to convert 开发者_如何学Cdecimal[] to double[]?

What's an efficient and hopefully elegant incantation to convert 开发者_如何学Cdecimal[] to double[]? I'm working with some fairly large arrays.


double[] doubleArray = Array.ConvertAll(decimalArray, x => (double)x);


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();
0

精彩评论

暂无评论...
验证码 换一张
取 消