C# 中意大利语的星期几名称
Name of day of week in italian language in c#
我无法使用 c# 在我的 aspx 页面中提取意大利语的星期几名称。
我试过这个解决方案,但在输出中我有星期五,有什么问题吗?
DateTime ItalianJobCookie = DateTime.Parse(Request.Cookies["ItalianJob"].Value);
string ItalianJobCookieDayName = ItalianJobCookie.DayOfWeek.ToString("G", new CultureInfo("it-IT"));
Response.Write(ItalianJobCookieDayName.ToString());
DayOfWeek
是文化不变的。它总是 returns 基于英语的 日名称。
来自文档;
The members of the DayOfWeek enumeration are not localized. To return
the localized name of the day of the week, call the
DateTime.ToString(String) or the DateTime.ToString(String,
IFormatProvider) method with either the "ddd" or "dddd" format
strings. The former format string produces the abbreviated weekday
name; the latter produces the full weekday name.
您需要使用具有 it-IT
文化的 dddd
format specifier。
string ItalianJobCookieDayName = ItalianJobCookie.ToString("dddd", new CultureInfo("it-IT"));
DateTime.DayOfWeek
returns 给定 DateTime 的 DayOfWeek
不支持不同文化的 ToString
。这甚至是 documented:
The members of the DayOfWeek enumeration are not localized. To return
the localized name of the day of the week, call the
DateTime.ToString(String) or the DateTime.ToString(String,
IFormatProvider) method with either the "ddd" or "dddd" format
strings. The former format string produces the abbreviated weekday
name; the latter produces the full weekday name.
而是与 DateTime
一起使用
string ItalianJobCookieDayName = ItalianJobCookie.ToString("dddd");
如果当前文化是意大利语,否则:
string ItalianJobCookieDayName = ItalianJobCookie.ToString("dddd", new CultureInfo("it-IT"));
如果您想要缩写的日期名称,请使用 ddd
而不是 dddd
。 Further informations.
我无法使用 c# 在我的 aspx 页面中提取意大利语的星期几名称。
我试过这个解决方案,但在输出中我有星期五,有什么问题吗?
DateTime ItalianJobCookie = DateTime.Parse(Request.Cookies["ItalianJob"].Value);
string ItalianJobCookieDayName = ItalianJobCookie.DayOfWeek.ToString("G", new CultureInfo("it-IT"));
Response.Write(ItalianJobCookieDayName.ToString());
DayOfWeek
是文化不变的。它总是 returns 基于英语的 日名称。
来自文档;
The members of the DayOfWeek enumeration are not localized. To return the localized name of the day of the week, call the DateTime.ToString(String) or the DateTime.ToString(String, IFormatProvider) method with either the "ddd" or "dddd" format strings. The former format string produces the abbreviated weekday name; the latter produces the full weekday name.
您需要使用具有 it-IT
文化的 dddd
format specifier。
string ItalianJobCookieDayName = ItalianJobCookie.ToString("dddd", new CultureInfo("it-IT"));
DateTime.DayOfWeek
returns 给定 DateTime 的 DayOfWeek
不支持不同文化的 ToString
。这甚至是 documented:
The members of the DayOfWeek enumeration are not localized. To return the localized name of the day of the week, call the DateTime.ToString(String) or the DateTime.ToString(String, IFormatProvider) method with either the "ddd" or "dddd" format strings. The former format string produces the abbreviated weekday name; the latter produces the full weekday name.
而是与 DateTime
string ItalianJobCookieDayName = ItalianJobCookie.ToString("dddd");
如果当前文化是意大利语,否则:
string ItalianJobCookieDayName = ItalianJobCookie.ToString("dddd", new CultureInfo("it-IT"));
如果您想要缩写的日期名称,请使用 ddd
而不是 dddd
。 Further informations.