I. J. Kennedy
I. J. Kennedy

Reputation: 25819

convert Decimal array to Double array

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

Upvotes: 25

Views: 24211

Answers (2)

Victor
Victor

Reputation: 47

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

Upvotes: 3

LukeH
LukeH

Reputation: 269358

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

Upvotes: 55

Related Questions