c# - 删除最大值

标签 c# list linq

我正在尝试删除具有最大值的条目以更改程序的行为。我试过 LINQ,但出现以下错误:

CS1936 C# Could not find an implementation of the query pattern for source type 'long'. 'Where' not found.

错误在 maxValue 内的 stanDev 上。我该如何更正错误? 代码是:

if (DailyStandard.Count() > 10)
{
    var dailyAvg = DailyStandard.Average(f => f.functionTime);
    var standDev = StandardDeviation(DailyStandard.Select(x => x.functionTime).ToList());
    var maxValue = from item in standDev
                   where item.max()
                   select item;
    maxValue.Remove();

最佳答案

你可以这样做:

DailyStandard = DailyStandard.OrderByDescending(f => f.functionTime).Skip(1).ToList();

Skip(1) 将删除集合中的第一项,该项已按 functionTime 降序排列。因此它将删除 DailyStandard 中具有最高 functionTime 的单个项目。

关于c# - 删除最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50632350/

相关文章:

c# - DelegateHandler 的 DI 无法正常工作

java - 删除单链表中的重复项保留顺序

c# - 将 IEnumerable<T> 转换为 IEnumerator<T> 有什么作用

c# - 与 System.Linq.IQueryable 结合得到错误

c# - EF4 CTP5 Code First 中的级联删除对子记录执行更新

c# - 从 List<ItemDetails> 是实体的类创建 XML

c - 为什么主函数中不打印链表?

c# - 使用 var 匿名对象为 LINQ 获取 InvalidCastException

c# - 快速将非常大的 BigInteger 写入 .txt 文件

python - 我需要使两个列表相同