日期:2014-05-18  浏览次数:20995 次

C# 字串数组如何转换为双精度数组
string aa = "10,13,13,45";
string[] st = aa.Split(',');
double[] d = new double[4];
d = Convert.ToDouble(st);

最后一句提示:
错误 1 无法将类型“double”隐式转换为“double[]”
请问如何解决啊。谢谢!!

------解决方案--------------------
C# code

            string aa = "10,13,13,45";
            string[] st = aa.Split(',');
            double[] d = new double[4];
            d = st.Select(x => new { num = Convert.ToDouble(x) }).Select(v => v.num).ToArray();

------解决方案--------------------
C# code
string[] st = aa.Split(',');
double[] ds = Array.ConvertAll(st, v1 => double.Parse(v1));