Getting current culture day names in .NET

后端 未结 9 958
情书的邮戳
情书的邮戳 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:57

    One more idea, inspired by Josh's answer, using a Queue instead of shifting the array.

    var days = CultureInfo.CurrentCulture.DateTimeFormat.DayNames;
    if (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "en")
    {
        var q = new Queue(days);
        q.Enqueue(q.Dequeue());
        days = q.ToArray();
    }
    

提交回复
热议问题