Getting current culture day names in .NET

后端 未结 9 885
情书的邮戳
情书的邮戳 2021-01-11 18:32

Is it possible to get the CurrentCulture\'s weekdays from DateTimeFormatInfo, but returning Monday as first day of the week instea

9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 18:46

    Since only one day is being moved, I solved this problem like this:

    'the list is from Sunday to Saturday
    'we need Monday to Sunday
    'so add a Sunday on the end and then remove the first position
    dayNames.AddRange(DateTimeFormatInfo.CurrentInfo.DayNames)
    dayNames.Add(DateTimeFormatInfo.CurrentInfo.GetDayName(DayOfWeek.Sunday))
    dayNames.RemoveAt(0)
    

提交回复
热议问题