Get WeekOfDay in c#

Get WeekOfDay in c#

public int GetWeekOfDay(int year, int month)
    {
        int tday = DateTime.DaysInMonth(year, month);
        int countSunday = 0, countSaturday = 0;
        for (int i = 0; i < tday; ++i)
        {
            DateTime d = new DateTime(year, month, i + 1);
            //Compare date with sunday
            if (d.DayOfWeek == DayOfWeek.Sunday)
            {
                countSunday = countSunday + 1;
            }
            if (d.DayOfWeek == DayOfWeek.Saturday)
            {
                if (countSaturday < 2)
                {
                    countSaturday = countSaturday + 1;
                }
            }
        }
        int totalSunday = countSunday;
        int totalSaturday = countSaturday;
        int totalWeekOff = countSunday + countSaturday;
        return totalWeekOff;
    }

2020-02-22