!fi.N-6ren">
gpt4 book ai didi

c# - LINQ 如何向这条语句添加一个 order by?

转载 作者:行者123 更新时间:2023-11-30 15:48:42 25 4
gpt4 key购买 nike

我有以下 LINQ,我也想按文件创建日期排序,这是怎么做到的?

taskFiles = taskDirectory.GetFiles(Id + "*.xml")
.Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase))
.ToArray();

最佳答案

taskFiles = taskDirectory.GetFiles(Id + "*.xml")
.Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase))
.OrderBy(fi => fi.CreationTime)
.ToArray();

var taskFiles = from taskFile in taskDirectory.GetFiles(Id + "*.xml")
where !taskFile.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase)
orderby taskFile.CreationTime
select taskFile;

关于c# - LINQ 如何向这条语句添加一个 order by?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2398616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com