//1.列为数字类型 double total= Convert.ToDouble(datatable.Compute("SUM(需要求和的参数)", "")); dt.Compute("sum(数量)", "TRUE") //2.列为string 类型 先转为数字类型 再求和 //有点问题,报错 double total= dt.AsEnumerable().Select(d => Convert.ToDouble(d.Field("amount"))).Sum();
标签:Convert,C#,求和,ToDouble,一列,total,DataTable From: https://www.cnblogs.com/derekhan/p/16721365.html