改变System.Globalization.NumberFormatInfo货币符号的位置 [英] Changing Currency Symbol location in System.Globalization.NumberFormatInfo

查看:232
本文介绍了改变System.Globalization.NumberFormatInfo货币符号的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用新的CultureInfo(FR-FR)CultureInfo对象。现在我有一个数字,我要打电话的ToString(C,FrenchCultureInfo)。结果字符串放€号码后。为什么呢?

I created a CultureInfo object using new CultureInfo("fr-FR"). Now I have a number that I want to call .ToString("C", FrenchCultureInfo). The resulting string puts the € AFTER the number. Why?

CultureInfo french = new CultureInfo("fr-FR");
double value = 1234.56;
string output = value.ToString("C", french);//output = "1 234,56 €"

这是我所见过的,欧洲需要在左边,我的业务需求的任务,这是在左边。但是,没有办法以编程方式设置此值。

From all I've seen, the Euro needs to be on the left, and my business requirements mandate that it is on the left. However, there is no way to programmatically set this value.

如何,我可以很容易地将这个值设置任何想法?我已经开始采取了美国的文化对象,并复制了从法国文化交给它,因为我们仍然希望所有的其他法国设置,除了欧元对正确的价值。但这种方法是非常耗时和令人沮丧的。

Any ideas on how I can set this value easily? I have started to take a US culture object and copy everything from the French culture over to it, since we still want all the other French settings, except for the Euro on the right value. But this method is very time consuming and frustrating.

谢谢!

推荐答案

克隆原来,然后修改它:

Clone the original and then modify it:

CultureInfo french = new CultureInfo("fr-FR");
french = (CultureInfo) french.Clone();
// Adjust these to suit
french.NumberFormat.CurrencyPositivePattern = 2;
french.NumberFormat.CurrencyNegativePattern = 2;
double value = 1234.56;
string output = value.ToString("C", french);//output = "€ 1 234,56"

请注意,这只会影响特定的CultureInfo 的对象,不是一般获得法国一个 - 所以你需要确保你在任何地方使用它

Note that this will only affect that specific CultureInfo object, not the one obtained for French in general - so you'll need to make sure you use it everywhere.

这篇关于改变System.Globalization.NumberFormatInfo货币符号的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆