var money = ds.AsEnumerable().GroupBy(g => g["SupplierCode"]).Select(s => s.Sum(t => (decimal)t["Money"])).ToList(); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn { ColumnName = "a", DataType = Type.GetType("System.String") }); dt.Columns.Add(new DataColumn { ColumnName = "b", DataType = Type.GetType("System.String") }); dt.Columns.Add(new DataColumn { ColumnName = "c", DataType = Type.GetType("System.DateTime") }); dt.Columns.Add(new DataColumn { ColumnName = "d", DataType = Type.GetType("System.DateTime") }); dt.Columns.Add(new DataColumn { ColumnName = "e", DataType = Type.GetType("System.Decimal") }); dt.Columns.Add(new DataColumn { ColumnName = "f", DataType = Type.GetType("System.String") }); DataRow dr = dt.NewRow(); dr["a"] = "1"; dr["b"] = 2;//ddlDept.SelectedText; dr["c"] = 3; dr["d"] = 4; dr["e"] = 5; dr["f"] =6; dt.Rows.Add(dr);
标签:Type,新增,System,Add,new,dt,dr,DataTable,赋值 From: https://www.cnblogs.com/Angdybo/p/17014034.html