CSharp examples for System:DateTime Week
Add Weekdays
using System.Threading.Tasks; using System.Linq; using System.Globalization; using System.Collections.Generic; using System;/*from w ww. j a v a2 s . c o m*/ public class Main{ public static DateTime AddWeekdays(this DateTime date, int days) { var sign = days < 0 ? -1 : 1; var unsignedDays = Math.Abs(days); var weekdaysAdded = 0; while (weekdaysAdded < unsignedDays) { date = date.AddDays(sign); if (date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday) weekdaysAdded++; } return date; } }