What's an efficient and hopefully elegant incantation to convert decimal[]
to double[]
?
I'm working with some fairly large arrays.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
double[] doubleArray = Array.ConvertAll(decimalArray, x => (double)x);
回答2:
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();