日期:2014-05-17  浏览次数:21269 次

double数组怎么转换为dataset
double [] dou=new double []{1,2,3,4,5,6};
转换为一个dataset;

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

 private void tmp()
        {
            double[] dou = new double[] { 1, 2, 3, 4, 5, 6 };
            DataTable dt = new DataTable();
            dt.Columns.Add("temp", System.Type.GetType("System.Double"));
            DataRow row;
            for (int i = 0; i < dou.Length; i++)
            {
                row = dt.NewRow();
                row["temp"] = dou[i];
                dt.Rows.Add(row);
            }
        }

------解决方案--------------------
double[] dou = new double[] { 1, 2, 3, 4, 5, 6 };
DataTable dt = new DataTable();
dt.Columns.Add("id", typeof(double));
dou.ToList().ForEach(t => dt.Rows.Add(t));