Check if dateTime is a weekend or a weekday

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


        
6条回答
  •  野性不改
    2021-02-03 21:04

    You are comparing your ASP.NET label dayToday against an enumeration element of DayOfWeek which of course fails

    Probably you want to replace dayToday with day in your if statement, i.e. from

    if ((dayToday == DayOfWeek.Saturday) && (dayToday == DayOfWeek.Sunday))
    

    to

    if ((day == DayOfWeek.Saturday) && (day == DayOfWeek.Sunday))
    

    In addition, you probably also want to replace the logical 'and' (&&) with a logical 'or' (||) to finally

    if ((day == DayOfWeek.Saturday) || (day == DayOfWeek.Sunday))
    

提交回复
热议问题