显示货币格式 [英] Currency format for display

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

问题描述

有一个库来格式化为一个国家重新present正确的货币?

例 英国 - £127.54 荷兰€127,54- 美国$ 127.54

等。

有些事情要考虑,

  1. 货币符号

  2. 货币符号的位置 - 它可以 有两个地方之前或之后 数字。

  3. 负量显示

解决方案

尝试货币格式说明符(C)。它会自动将当前的UI文化考虑,并相应地显示货币价值。

您可以使用它与任何<一href="http://msdn.microsoft.com/en-us/library/system.string.format.aspx"><$c$c>String.Format或者重载的ToString 方法数值类型。

例如:

 双值= 12345.6789;
Console.WriteLine(value.ToString(C,CultureInfo.CurrentCulture));

Console.WriteLine(value.ToString(C3,CultureInfo.CurrentCulture));

Console.WriteLine(value.ToString(C3,CultureInfo.CreateSpecificCulture(DA-DK)));

//这个例子显示系统,其在下面的输出
//当前区域性为英语(美国):
// $ 12,345.68
// $ 12,345.679
// KR 12.345,679
 

Is there a library to format the correct currency represent for a country?

Example UK -£127.54 Netherlands € 127,54- USA $127.54

etc..

Some things to consider,

  1. Currency Symbol

  2. Currency symbol placement -- It can be either place before or after the digits.

  3. Negative-amount display

解决方案

Try the Currency Format Specifier ("C"). It automatically takes the current UI culture into account and displays currency values accordingly.

You can use it with either String.Format or the overloaded ToString method for a numeric type.

For example:

double value = 12345.6789;
Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture));

Console.WriteLine(value.ToString("C3", CultureInfo.CurrentCulture));

Console.WriteLine(value.ToString("C3", CultureInfo.CreateSpecificCulture("da-DK")));

// The example displays the following output on a system whose
// current culture is English (United States):
//       $12,345.68
//       $12,345.679
//       kr 12.345,679

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

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