casting from object[] array to double[] array

1 posts, 0 answers
  1. Abhi
    Abhi avatar
    38 posts
    Member since:
    Nov 2012

    Posted 18 Apr 2013 Link to this post

    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));
    var doubles = Array.ConvertAll<object, double>(objects, o => (double)o);
Back to Top