NextDayOfWeek

public static DateTime NextDayOfWeek(this DateTime dt, DayOfWeek day)
{
	var d = new GregorianCalendar().AddDays(dt, -((int)dt.DayOfWeek) + (int)day);
	return (d.Day < dt.Day) ? d.AddDays(7) : d;
}
Example:
DateTime.Now.NextDayOfWeek(DayOfWeek.Tuesday)

Description

Will return the next occurring day of week

Details

Double click on the code to select all.

 

;