c# how to calculate the working days left in a month
<p>Hi i am new to <code>c#</code> and programing in general i have been trying to learn from adapting other peoples code the code below i have changed the code as i want to calulate the amount of working days left in a month but the problem is the code runs over the amount of days in a month so this month has <strong>29 days</strong> but the code errors as the code runs to the <strong>30th</strong> I can not figure out which part of the code to change any help would be great   </p>

<pre><code>    private void days()
    {

        //Monday to Friday are business days.
        var weekends = new DayOfWeek[] { DayOfWeek.Saturday, DayOfWeek.Sunday };
        DateTime testing = DateTime.Now;



        string month1 = testing.ToString("M ");
        string year1 = testing.ToString("yyyy");
        int month = Convert.ToInt32(month1);
        int year = Convert.ToInt32(year1);


        //Fetch the amount of days in your given month.
        int daysInMonth = DateTime.DaysInMonth(year, month);
        string daysleft = testing.ToString("d ");
        int daystoday = Convert.ToInt32(daysleft);

        //Here we create an enumerable from 1 to daysInMonth,
        //and ask whether the DateTime object we create belongs to a weekend day,
        //if it doesn't, add it to our IEnumerable&lt;int&gt; collection of days.
        IEnumerable&lt;int&gt; businessDaysInMonth = Enumerable.Range(daystoday, daysInMonth)
                                               .Where(d =&gt; !weekends.Contains(new DateTime(year, month, d).DayOfWeek));

        //Pretty smooth.

        int count = 0;
        foreach (var day in businessDaysInMonth)
        {
            count = count + 1;
        }
        textBox9.Text = count.ToString();


    }
}
</code></pre>
