This project has moved. For the latest updates, please go here.

DoubleRange to array

Oct 4, 2012 at 7:39 PM

Is there a method for taking a doublerange variable and turning it into an array?  Or something better than looping? 

Oct 4, 2012 at 10:58 PM

Hi hillb,

Absolutely - all Range<T> classes have an ".AsEnumerable()" method which returns an IEnumerable<double> in your case. So, just use it as such:

double[] myDoubleArray = myDoubleRange.AsEnumberable().ToArray();

Note, if you don't already have it, you'll also need a "using System.Linq;" statement at the top of the file to get the ".ToArray()" extension method.

Hope this helps!

Oct 4, 2012 at 11:00 PM

Perfect, thanks David!