C#: Set initial DayOfWeek as Monday not Sunday

前端 未结 3 1468
醉酒成梦
醉酒成梦 2020-12-31 03:42

Is there a way to set the first DayOfWeek as Monday = 0 not Sunday?

(int)dateList[0].DayOfWeek == 0) // 0 = Sunday
3条回答
  •  梦毁少年i
    2020-12-31 04:26

    Just to complete this for people searching this issue, here is my simple workaround (VB.NET):

    Private Function GetTrueDayOfWeek(DayOfWeekUS As Int16)
        Dim RetVal As Int16 = 0
        If DayOfWeekUS = 0 Then
            RetVal = 7
        Else
            RetVal = DayOfWeekUS
        End If
        Return RetVal
    End Function
    

    Usage:

    Dim TrueDayInWeek as int16
    TrueDayInWeek = GetTrueDayOfWeek(dateList(0).DayOfWeek)
    

提交回复
热议问题