当使用CultureInfo.GetCultureInfo(字符串)或CultureInfo.CreateSpecificCulture(字符串)字符串、CultureInfo、GetCultureI

由网友(真的爱错了人)分享简介:当我应该叫的CultureInfo。CreateSpecificCulture(String)而随后的CultureInfo。GetCultureInfo(String). MSDN文档也不是很清楚。When should I call CultureInfo.CreateSpecificCulture(String...

当我应该叫的CultureInfo。CreateSpecificCulture(String)而随后的CultureInfo。GetCultureInfo(String). MSDN文档也不是很清楚。

When should I call CultureInfo.CreateSpecificCulture(String) rather then CultureInfo.GetCultureInfo(String). The MSDN documentation is not very clear.

也就是有没有办法更便宜的检查,如果一种文化的名称是有效的?

Also is there a way to cheaper check if the name of a culture is valid?

我的认为的,如果你通过恩而不是EN-GB为CultureInfo.CreateSpecificCulture(字符串),你会得到一个错误,但CultureInfo.GetCultureInfo(字符串)不介意。例如。 CultureInfo.GetCultureInfo(字符串)可以应付,如果你只是传递语言。 不过,我仍不清楚这一点。的

I think if you pass "en" rather then "en-GB" to CultureInfo.CreateSpecificCulture(String) you will get an error, but that CultureInfo.GetCultureInfo(String) does not mind. E.g. CultureInfo.GetCultureInfo(String) can cope if you only pass an language. However I am still unclear on this.

推荐答案

这取决于一点上你所需要的培养。短名称(EN,FR等)用于中性文化,足以满足特定语言资源管理。但对于数字和日期格式,你需要一个特定的文化,像EN-GB。

It depends a bit on what you need the culture for. The short names ("en", "fr" etc) are used for neutral cultures, sufficient for language specific resource management. But for numerical and date formatting you need a specific culture, like "en-GB".

CultureInfo.CreateSpecificCulture(EN); 正常工作在这里。它特别为了得到'A'特定的培养是中性的。

And CultureInfo.CreateSpecificCulture("en"); works fine over here. It is especially intended to get 'a' specific culture for a neutral one.

阅读全文

相关推荐

最新文章