代码如下:
//double num=dt.AsEnumerable().Select(row => Convert.ToDouble(row.Field<string>("Id"))).Sum(); //double num2 = dt.AsEnumerable().Sum(row => Convert.ToDouble(row.Field<string>("Id"))); double num = dt.AsEnumerable().Select(row => Convert.ToDouble(row["Id"])).Sum(); double num2 = dt.AsEnumerable().Sum(row => Convert.ToDouble(row["Id"]));