Next
Get next day of the week
Source
public static DateTime Next(this DateTime from, DayOfWeek dayOfWeek)
{
int start = (int)from.DayOfWeek;
int target = (int)dayOfWeek;
if (target <= start)
target += 7;
return from.AddDays(target - start);
}
Example
DateTime.Today.Next(DayOfWeek.Sunday)
Author: Thomas Levesque
Submitted on: 10 jun. 2021
Language: csharp
Type: System.DateTime
Views: 3280