列的绝对值之和我有下面的代码如何获得的数据表
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Data;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
//Your code goes here
DataTable dt = new DataTable();
dt.Columns.Add("Column1");
dt.Columns["Column1"].DataType = typeof(Int32);
dt.Rows.Add(1);
dt.Rows.Add(2);
dt.Rows.Add(-1);
int a = Convert.ToInt32(dt.Compute("SUM(Column1)", "Column1 < 10"));
Console.WriteLine(a);
}
}
}
它会给OP为2,这两个+已经不将被添加和-ve一个将被扣除。我需要4作为OP。我的意思是所有的abs值。怎么做?
你找[Math.Abs ](https://www.dotnetperls.com/math-abs) –