This is a migrated thread and some comments may be shown as answers.

casting from object[] array to double[] array

0 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Abhi
Top achievements
Rank 1
Abhi asked on 18 Apr 2013, 06:33 AM
Hi Team,
               I have an array of objects[] but I want to convert them to an array of doubles[]

               I tried in the following ways.............. but I got error (cannont implicitly convert object[] to double[])

              1. double[] values = (double[])o; (here o means object array)
             
              2. double[] values = o.Cast<double>().ToArray(typeof(double));
               
              3. 
var doubles = Array.ConvertAll<object, double>(objects, o => (double)o);

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Abhi
Top achievements
Rank 1
Share this question
or