C# 查找一周中的下一个活跃日
我正在使用一个 C# 类来表示一个配置文件,其中包含一些计划信息,指示一天中的更新次数,以及一周中每一天的布尔值更新的日期。我在这里和其他网站上看到了一些帖子,以查找给定工作日的下一个实例等,但没有找到可以改变的日期。
例如,我可能会得到一个星期一、星期三和星期四为 true 的对象。查找一周中下一个真实日期的下一个实例的最佳方法是什么?
我可以想出一些漫长而漫长的方法来找到一周中的下一个“真正”的一天,但是是否有一些我不熟悉的更干净的内置方法可以做到这一点?我不想使用任何第三方库,因为这需要信息保证人员的大量特别批准。
I've got a C# class I'm working with representing a profile that includes some scheduling information indicating how many updates during the day, and which days to update with boolean values for each day of the week. I've seen some posts here and on other sites to find the next instance of a given weekday, etc. but not something where which days one is looking for can vary.
For example, I might be given an object with Monday, Wednesday, and Thursday as true. What's the best way to find the next instance of the next true day of the week?
I can think of some long and drawn out ways to find the next "true" day of the week, but is there something cleaner built in that I'm unfamiliar with that would do the trick? I'd prefer not to use any third party libraries, as that requires lots of special approval from information assurance folks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
鉴于循环几乎不会花费很长时间,这将是最简单的方法:(
假设您已经验证该配置文件至少在一天内处于活动状态......否则它将永远循环。)
Given that it's hardly going to take a long time to loop, that's going to be the simplest approach:
(That's assuming you've already validated that the profile is active on at least one day... otherwise it'll loop forever.)