convert Decimal array to Double array

后端 未结 2 618
梦如初夏
梦如初夏 2021-02-12 10:10

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

相关标签:
2条回答
  • 2021-02-12 11:06

    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 讨论(0)
  • 2021-02-12 11:16
    double[] doubleArray = Array.ConvertAll(decimalArray, x => (double)x);
    
    0 讨论(0)
提交回复
热议问题