Find the number of working days between two dates inclusively The objective is to find the number of working days (days spanning from Monday to Friday) between two given dates inclusively.

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 13; i &lt;= 31; i++)
            {
                DateTime start = new DateTime(2014, 10, i);
                DateTime stop = new DateTime(2014, 10, 31);

                int totalWorkingDays = GetNumberOfWorkingDays(start, stop);

                Console.WriteLine("There are {1} working days from Oct {0}, 2014 to Oct 31, 2014.", i, totalWorkingDays);
            }
        }

        private static int GetNumberOfWorkingDays(DateTime start, DateTime stop)
        {
            TimeSpan interval = stop - start;

            int totalWeek = interval.Days / 7;
            int totalWorkingDays = 5 * totalWeek;

            int remainingDays = interval.Days % 7;


            for (int i = 0; i &lt;= remainingDays; i++)
            {
                DayOfWeek test = (DayOfWeek)(((int)start.DayOfWeek + i) % 7);
                if (test &gt;= DayOfWeek.Monday &amp;&amp; test &lt;= DayOfWeek.Friday)
                    totalWorkingDays++;
            }

            return totalWorkingDays;
        }
    }
}


Is there the simpler or better way to do so? Any comment and suggestion is welcome.
Personally, I think your approach is very complicated for what it should be trying to do: loop over all days between the start and the end date and count how many of those are not in the weekend.

Translating that sentence to code, gives me this:

private static int GetNumberOfWorkingDaysJeroen(DateTime start, DateTime stop)
{
    int days = 0;
    while(start &lt;= stop)
    {
        if(start.DayOfWeek != DayOfWeek.Saturday &amp;&amp; start.DayOfWeek != DayOfWeek.Sunday)
        {
            ++days;
        }
        start = start.AddDays(1);
    }
    return days;
}


I find this much easier to interpret than a bunch of modulos, casts and divisions.