.NET Chinese CultureInfo "zh" 不存在?

.NET Chinese CultureInfo "zh" does not exist?

我正在使用 .NET 3.5 和 运行 以下代码:

var culture = new CultureInfo("zh"); // Throws ArgumentException

我从 xml:lang 属性中得到字符串 "zh"。我不明白为什么抛出异常,因为例如 "de"("de-DE" 的父级)工作正常。文化 "zh-CN" 确实有效,但那不是我可以使用的。

编辑: 它适用于 .NET 4.5.1(感谢 xanatos)——因此即使 MSDN 页面解释说中文是一个例外,但在较新的 .NET 版本中行为是不同的。

CultureInfo页面有小提示:

There are two culture names that contradict this rule. The cultures Chinese (Simplified), named zh-Hans, and Chinese (Traditional), named zh-Hant, are neutral cultures. The culture names represent the current standard and should be used unless you have a reason for using the older names zh-CHS and zh-CHT.

所以你可以尝试 zh-Hanszh-Hant

And/or 你可以看到 What cultures are supported by the CultureInfo class in .NET 3.5?

接受的答案是:

Unfortunately, it is OS dependent. Check here for default language support per OS.

在 .NET 3.5 中,"zh" 不起作用,请改用 "zh-Hans" 或 "zh-Hant"。没有找到更好的解决方案。或者切换到 .NET 4.5。