找到跟目标值最近的linq写法
记下来,备查
// validDataInChart double 数组
var result = (from x in validDataInChart select new { Key = x, Value = Math.Abs(x - newY) }).OrderBy(x => x.Value); newY = result.ToList()[0].Key;
记下来,备查
// validDataInChart double 数组
var result = (from x in validDataInChart select new { Key = x, Value = Math.Abs(x - newY) }).OrderBy(x => x.Value); newY = result.ToList()[0].Key;