Get remaining days in date range I wonder if there are some possible ways to simplify my code. 

startDate = '04/02/2014'
endDate = '04/06/2014'

mondayTag = 0
tuesdayTag = 0
wednesdayTag = 1
thursdayTag = 0
fridayTag = 1
saturdayTag = 0
sundayTag = 0

public int GetRemainingDays(DateTime startDate, DateTime endDate, bool mondayTag, bool tuesdayTag, bool wednesdayTag, bool thursdayTag, bool fridayTag, bool saturdayTag, bool sundayTag)
{
    int i = 0;
    for (DateTime day = startDate.AddDays(1); day.Date &lt;= endDate.Date; day = day.AddDays(1))
    {
        if (day.DayOfWeek == DayOfWeek.Monday &amp;&amp; mondayTag == true)
        {
            i = i + 1;
        }
        else if (day.DayOfWeek == DayOfWeek.Tuesday &amp;&amp; tuesdayTag == true)
        {
            i = i + 1;
        }
        else if (day.DayOfWeek == DayOfWeek.Wednesday &amp;&amp; wednesdayTag == true)
        {
            i = i + 1;
        }
        else if (day.DayOfWeek == DayOfWeek.Thursday &amp;&amp; thursdayTag == true)
        {
            i = i + 1;
        }
        else if (day.DayOfWeek == DayOfWeek.Friday &amp;&amp; fridayTag == true)
        {
            i = i + 1;
        }
        else if (day.DayOfWeek == DayOfWeek.Saturday &amp;&amp; saturdayTag == true)
        {
            i = i + 1;
        }
        else if (day.DayOfWeek == DayOfWeek.Sunday &amp;&amp; sundayTag == true)
        {
            i = i + 1;
        }
    }
    return i &gt; 0 ? i : 0;
}
Using System.Linq library the method can be rewritten like this:

public static int GetRemainingDays(DateTime startDate, DateTime endDate, ISet&lt;DayOfWeek&gt; includedDays)
{
    return Enumerable.Range(0, Int32.MaxValue)
        .Select(n =&gt; startDate.AddDays(n+1))
        .TakeWhile(date =&gt; date &lt;= endDate)
        .Count(date =&gt; includedDays.Contains(date.DayOfWeek));
}


Which can then be more easily called like this:

GetRemainingDays(startDate, endDate, 
    new HashSet&lt;DayOfWeek&gt;{DayOfWeek.Wednesday, DayOfWeek.Friday});


Note: You should test this (and the original version) against off-by-one errors.