gpt4 book ai didi

c# - C# 中意大利语的星期几名称

转载 作者:太空狗 更新时间:2023-10-30 00:30:59 24 4
gpt4 key购买 nike

我无法使用 C# 在我的 aspx 页面中提取意大利语的星期几名称。

我已经尝试过这个解决方案,但在输出中我有星期五,有什么问题吗?

DateTime ItalianJobCookie = DateTime.Parse(Request.Cookies["ItalianJob"].Value);
string ItalianJobCookieDayName = ItalianJobCookie.DayOfWeek.ToString("G", new CultureInfo("it-IT"));

Response.Write(ItalianJobCookieDayName.ToString());

最佳答案

DateTime.DayOfWeek 返回给定 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 而不是 ddddFurther informations .

关于c# - C# 中意大利语的星期几名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31243066/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com