convert Decimal array to Double array

后端 未结 2 622
梦如初夏
梦如初夏 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条回答
  •  梦毁少年i
    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();
    

提交回复
热议问题