I have a list of DayOfWeek enum item: var daysOfWeek = List<DayOfWeek>
This list contains a variable amount of DaysOfWeek items, e.g. Monday, Thursday, Saturday.
I would like to find the next DateTime to any given DateTime based on List<DayOfWeek>
.
If the given date would fall on a Wednesday, the next DateTime which should return would be a Thursday.
If the given date would fall on a Thursday, the next DateTime which should return would be a Saturday.
So far, I have been fiddling around with the some LINQ expressions and trying some options with the Min() extension method but have no code which I could share that would be workable. I am wondering if I am missing some real basic LINQ functionality.
SO-Topics that have given me some ideas so far include this one and that one, however I was not able to produce a solution for my problem with their answers.