R10*_*100 5 .net c# asp.net currency string-formatting
我正在使用CultureInfo方法将所有不同的货币成功格式化为正确的格式.
但在某些例外情况下,例如欧元和瑞典克朗的货币,我需要能够在价值之后添加它们.目前,我的CultureInfo正在按以下方式格式化它们:"SEK 1.00,00",当它需要"1.00,00 SEK"时.
任何帮助表示赞赏.
您所需要的只是改变文化的属性NumberFormatInfo.CurrencyPositivePattern和NumberFormatInfo.CurrencyNegativePattern属性.
只是克隆原始文化:
CultureInfo swedish = new CultureInfo("sv-SE");
swedish = (CultureInfo)swedish.Clone();
swedish.NumberFormat.CurrencyPositivePattern = 3;
swedish.NumberFormat.CurrencyNegativePattern = 3;
Run Code Online (Sandbox Code Playgroud)
然后
var value = 123.99M;
var result = value.ToString("C", swedish);
Run Code Online (Sandbox Code Playgroud)
应该给你想要的结果.这应该会让你:
123,99 kr
| 归档时间: |
|
| 查看次数: |
4942 次 |
| 最近记录: |