Check if dateTime is a weekend or a weekday

前端 未结 6 1908
日久生厌
日久生厌 2021-02-03 20:48


        
6条回答
  •  孤独总比滥情好
    2021-02-03 21:04

            List datelist = new List();
    
            int balanceday = 1;
            while (datelist.Count < 10)
            {
                DateTime day = DateTime.Now.AddDays(balanceday + datelist.Count).Date;
                if (day.DayOfWeek != DayOfWeek.Saturday && day.DayOfWeek != DayOfWeek.Sunday)
                {
                    datelist.Add(day);
                }
                else
                {
                    balanceday++;
                }
            }
    

提交回复
热议问题