Write an extension method to exclude the weekends.
public static class ExtensionMethods
{
public static int GetNumberOfWorkingDays(this DateTime startDate, DateTime endDate)
{
int numberOfWorkingDays = 0;
for (var nextDate = startDate; nextDate < endDate; nextDate = nextDate.AddDays(1))
{
if (nextDate.DayOfWeek != DayOfWeek.Saturday && nextDate.DayOfWeek != DayOfWeek.Sunday)
{
++numberOfWorkingDays;
}
}
return numberOfWorkingDays;
}
}
and then call it from your code, e.g.
var startDate = DateTime.Now;
var endDate = startDate.AddDays(10);
var numberDays = startDate.GetNumberOfWorkingDays(endDate);