This project has moved and is read-only. For the latest updates, please go here.

DoubleRange to array

Oct 4, 2012 at 8: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 11: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 5, 2012 at 12:00 AM

Perfect, thanks David!