更改 System.Globalization.NumberFormatInfo 中的货币符号位置
我使用 new CultureInfo("fr-FR") 创建了一个 CultureInfo 对象。现在我有一个号码要调用 .ToString("C", FrenchCultureInfo)。生成的字符串将 € 放在数字后面。为什么?
CultureInfo french = new CultureInfo("fr-FR");
double value = 1234.56;
string output = value.ToString("C", french);//output = "1 234,56 €"
据我所知,欧元需要位于左侧,而我的业务要求要求它位于左侧。但是,无法以编程方式设置该值。
关于如何轻松设置这个值有什么想法吗?我已经开始采用美国文化对象并将法国文化的所有内容复制到其中,因为我们仍然想要所有其他法国设置,除了欧元以外的正确价值。但这种方法非常耗时且令人沮丧。
谢谢!
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.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
克隆原始对象,然后对其进行修改:
请注意,这只会影响特定的
CultureInfo
对象,而不是一般为法语获得的对象 - 因此您需要确保在任何地方都使用它。Clone the original and then modify it:
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.