Because you never know how many days could be between Monday and Friday

Why do a couple of subtractions when two loops can do the same work?

while (processDate.DayOfWeek != DayOfWeek.Monday)
    processDate = processDate.AddDays(-1);
 
string mondayDate = processDate.ToShortDateString();
 
while (processDate.DayOfWeek != DayOfWeek.Friday)
    processDate = processDate.AddDays(1);
 
string fridayDate = processDate.ToShortDateString();

One Comment

  1. John Boker says:

    that code looks familiar…

Leave a Reply