我正在尝试使用以下方法更改内置的.Net文化fr-CA:
I'm attempting to change the built in .Net culture fr-CA, using the following method:
CultureAndRegionInfoBuilder cib = new CultureAndRegionInfoBuilder("fr-CA", CultureAndRegionModifiers.Replacement); try { Console.WriteLine("Updating " + cib.CultureName); cib.NumberFormat.CurrencyGroupSeparator = ","; cib.NumberFormat.CurrencyDecimalSeparator = "."; cib.NumberFormat.NumberGroupSeparator = ","; cib.NumberFormat.NumberDecimalSeparator = "."; cib.Register(); Console.WriteLine("Culture updated."); } catch (Exception e) { Console.WriteLine(e); Console.ReadKey(); }但是,Register()调用失败,并显示"System.InvalidOperationException:'Register'方法失败,因为自定义区域性'fr-CA'已经存在."
However, the Register() call fails with "System.InvalidOperationException: The 'Register' method failed because the custom culture 'fr-CA' already exists."
是否可以更新内置文化?根据文档( msdn.microsoft /en-us/library/system.globalization.cultureandregioninfobuilder.cultureandregioninfobuilder.aspx ),尽管我可能读错了它,但我似乎只能对其进行更新.
Is it possible to update the built-in culture? According to the docs (msdn.microsoft/en-us/library/system.globalization.cultureandregioninfobuilder.cultureandregioninfobuilder.aspx), it looks like I can just update it, though I might be reading that wrong.
推荐答案我只需要添加:
CultureAndRegionInfoBuilder.UnRegister("fr-CA");在Register()之前.
before Register().
更多推荐
使用CultureAndRegionInfoBuilder更新内置的.Net文化
发布评论