c# - 为什么不同机器上的相同文化给出不同的缩写月份?

标签 c# datetime cultureinfo culture

我与同事的文化相同,但得到了不同的月份缩写。

var x = new DateTime(2023, 9, 27);
Console.WriteLine(x.ToString("MMM", new CultureInfo("en-GB")));

当面向 .Net 6 时,在 Windows 10 上我得到 Sep,但在 Windows 11 上我得到 Sept

每个实例中都使用默认的DateTimeFormatInfo.AbbreviatedMonthNames。为什么会出现这种情况?

最佳答案

看来操作系统是造成这种行为的原因。微软CultureInfo docs (如 another Stack Overflow answer 中所述)说明以下内容:

The culture names and identifiers represent only a subset of cultures that can be found on a particular computer. Windows versions or service packs can change the available cultures. Applications can add custom cultures using the CultureAndRegionInfoBuilder class. Users can add their own custom cultures using the Microsoft Locale Builder tool. Microsoft Locale Builder is written in managed code using the CultureAndRegionInfoBuilder class.

有点不清楚这是否仅仅意味着可以添加和减去可用区域性集合,或者是否可以编辑区域性内容。然而,我和我的同事看到的不同的缩写月份名称意味着内容可以被操作系统修改。

值得注意这一点,因为许多开发人员可能认为给定的文化在任何操作系统上都是相同的。

关于c# - 为什么不同机器上的相同文化给出不同的缩写月份?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76324360/

相关文章:

c# - 告诉 Web 引用使用 web.config 或如何使 settings.settings 可编辑

c# - 在 Linq 中删除查询

javascript - 如何禁用 GridView 中的 LinkBut​​ton

c# - 从当前线程区域性获取语言环境代码

c# - 通过 Action 而不是 Hook PropertyChanged?

c# - 为什么 IS NULL 有效但 SQL Parameter with DBNull.Value for DateTime 不起作用?

java - 在 joda time 中创建自定义日历

python - 在python中从日期时间转换为日期字符串

c# - 按货币获取文化

c# - CultureInfo 转换 (C#)