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 <= endDate.Date; day = day.AddDays(1))
{
if (day.DayOfWeek == DayOfWeek.Monday && mondayTag == true)
{
i = i + 1;
}
else if (day.DayOfWeek == DayOfWeek.Tuesday && tuesdayTag == true)
{
i = i + 1;
}
else if (day.DayOfWeek == DayOfWeek.Wednesday && wednesdayTag == true)
{
i = i + 1;
}
else if (day.DayOfWeek == DayOfWeek.Thursday && thursdayTag == true)
{
i = i + 1;
}
else if (day.DayOfWeek == DayOfWeek.Friday && fridayTag == true)
{
i = i + 1;
}
else if (day.DayOfWeek == DayOfWeek.Saturday && saturdayTag == true)
{
i = i + 1;
}
else if (day.DayOfWeek == DayOfWeek.Sunday && sundayTag == true)
{
i = i + 1;
}
}
return i > 0 ? i : 0;
}