日期:2014-05-17 浏览次数:21243 次
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));