问题描述
我正在使用.NET 3.5并运行以下代码:
I'm using .NET 3.5 and running the following code:
var culture = new CultureInfo("zh"); // Throws ArgumentException
我从xml:lang属性中获得了字符串 zh。我不明白为什么会引发异常,因为例如 de( de-DE的父代)工作正常。文化 zh-CN确实有效,但是我不能使用。
I got the string "zh" from an xml:lang attribute. I don't understand why an exception is thrown, because for instance "de" (wich is parent for "de-DE") is working fine. The culture "zh-CN" does work, but thats nothing that I can use.
编辑:
它适用于。 NET 4.5.1(感谢xanatos)-因此,即使MSDN页面解释为中文是一个例外,在较新的.NET版本中,行为也有所不同。
It works on .NET 4.5.1 (thanks to xanatos) - so even if the MSDN page explains that Chinese is an exception, the behaviour is different in newer .NET versions.
推荐答案
在.NET 3.5中, zh不起作用,请改用 zh-Hans或 zh-Hant。找不到更好的解决方案。或切换到.NET 4.5。
In .NET 3.5 "zh" does not work, use "zh-Hans" or "zh-Hant" instead. Didn't find a better solution. Or switch to .NET 4.5.
这篇关于.NET中国文化信息“ zh”不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!