在值后显示货币符号 [英] Show Currency Symbol after values

查看:72
本文介绍了在值后显示货币符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CultureInfo方法将所有不同的货币成功地格式化为正确的格式。

I am using CultureInfo methods to successfully format all different currencies into their correct format.

但是在某些例外情况下,例如欧元和瑞典克朗,我需要能够在值之后添加它们。目前,我的CultureInfo正在以以下方式格式化它们: SEK 1.00,00(当它需要为 1.00,00 SEK时。)。

But on some exceptions, such as EUR and SEK currencies I need to be able to add them after the value. At the moment my CultureInfo is formatting them in the following way: "SEK 1.00,00" when it needs to be "1.00,00 SEK".

我们将为您提供任何帮助。

Any help is appreciated.

推荐答案

您所需要做的就是更改 NumberFormatInfo.CurrencyPositivePattern 文化的 NumberFormatInfo.CurrencyNegativePattern 属性。

All you need is to change the NumberFormatInfo.CurrencyPositivePattern and NumberFormatInfo.CurrencyNegativePattern properties for the culture.

只需克隆原始文化:

CultureInfo swedish = new CultureInfo("sv-SE");
swedish = (CultureInfo)swedish.Clone();
swedish.NumberFormat.CurrencyPositivePattern = 3;
swedish.NumberFormat.CurrencyNegativePattern = 3;

然后

var value = 123.99M;
var result = value.ToString("C", swedish);

应该给您想要的结果。这应该可以让您:

should give you desired result. This should get you:


123,99 kr

123,99 kr

这篇关于在值后显示货币符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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