显示货币格式 [英] Currency format for display
问题描述
有一个库来格式化为一个国家重新present正确的货币?
例 英国 - £127.54 荷兰€127,54- 美国$ 127.54
等。
有些事情要考虑,
-
货币符号
-
货币符号的位置 - 它可以 有两个地方之前或之后 数字。
-
负量显示
尝试货币格式说明符(C)。它会自动将当前的UI文化考虑,并相应地显示货币价值。
您可以使用它与任何<一href="http://msdn.microsoft.com/en-us/library/system.string.format.aspx"><$c$c>String.Format$c$c>或者重载的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,
Currency Symbol
Currency symbol placement -- It can be either place before or after the digits.
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屋!