public class BatchProcess
{
public string process { get; set; }
public DateTime runtime { get; set; }
public bool running { get; set; }
}
所以我有这些人的名单 - List<BatchProcess> list
.
我将如何根据这些列中的每一列进行排序?我听说我可以用 LINQ 做到这一点,但我对 LINQ 很不满意。那看起来怎么样?
谢谢。
最佳答案
您可以按运行时间排序,例如,通过:
var orderedByRuntime = list.OrderBy(p => p.runtime);
如果你想按“进程”降序排序,你可以使用:
var orderedByProcessDesc = list.OrderByDecending(p => p.process);
关于c# - 在 C# 中对列表进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6417253/