I want to convert a List<float[]>
to List<double[]>
List<float[]> f=new List<float[]>();
List<double[]> d=new List<double[]>();
// ...add float arrays to f...
d.AddRange((doulbe[])f); // Cannot convert type float[] to double[]
is there a way to cast this? so that it won't require a for loop, because I have many lists to be converted.
You can use:
d.AddRange(f.Select(flArray => Array.ConvertAll(flArray, f => (double)f)));
or:
f.ForEach(flArray => d.Add(Array.ConvertAll(flArray, f => (double)f)));