如何大写的ToLongDateString()结果ES-MX文化日期和月份的第一个字母?第一个、字母、日期、结果

2023-09-03 02:48:47 作者:君离谁相惜

目前,我从下面的C#线code时,在ES-MX文化

currently i obtain the below result from the following C# line of code when in es-MX Culture

   Thread.CurrentThread.CurrentCulture =
     Thread.CurrentThread.CurrentUICulture = new
                CultureInfo("es-mx");

  <span><%=DateTime.Now.ToLongDateString()%></span>

miércoles,22日OCTUBRE日2008

我想获得以下

miércoles, 22 de octubre de 2008

i would like to obtain the following

我是否需要建立自己的文化?

do i need to Build my own culture?

推荐答案

您不需要建立自己的文化。你只需要更改的属性DateTimeFormat.DayNames和DateTimeFormat.MonthNames在当前的文化。

You don't need to build your own culture. You only need to change the property DateTimeFormat.DayNames and DateTimeFormat.MonthNames in the current culture.

        string[] newNames = { "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado", "Domingo" };
        Thread.CurrentThread.CurrentCulture.DateTimeFormat.DayNames = newNames;

然而,这是奇怪的是EN-美剧月份和日期与第一大写字母和MX-ES不是。

However, it's weird that en-US show months and days with the first uppercase letter and for mx-ES not.

希望它能帮助!