有没有办法为一个国家/地区设置正确的货币表示格式?
例子 英国 - £127.54 荷兰 € 127,54- 美国 $127.54
等..
一些需要考虑的事情,
货币符号
货币符号放置 -- 可以 位于之前或之后 数字。
负数显示
最佳答案
试试 Currency Format Specifier (“C”)。它会自动考虑当前的 UI 文化并相应地显示货币值。
您可以将它与 String.Format
一起使用或为数字类型重载的 ToString
方法。
例如:
decimal value = 12345.6789M; // Be sure to use Decimal for money values. Do not use IEEE-754 types such as float (System.Single) and double (System.Double) as they can only store approximate values.
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
关于c# - 显示的货币格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4842332/