正如标题所说:
我有一个 DateTime start
和一个 DateTime stop
现在我想将这些与 List<DateTime> dates
进行比较
我只想检查列表 dates
介于 start
之间和 stop
if(dates.all(..... >= start && <= stop)) {
. do something
}
最佳答案
您问题中的伪代码与您正在寻找的工作代码相距不远。
使用 LINQ 的 All()方法:
if (dates.All(date => date >= start && date <= stop)) {
// Do something.
}
关于c# 比较 DateTime start 和 DateTime stop 与 List<DateTime>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5935941/