如果我有类似的话:
Decimal moneyAmount = -1522;
然后致电
moneyAmount.toString("c");
它会返回类似的内容:
($一五二二)
相反,我希望有一个负面的迹象,没有假设。如何修改我发送给toString()的格式提供程序,以便实现以下效果:
- $一千五百二十二
答案 0 :(得分:8)
取自:http://keithdevens.com/weblog/archive/2007/Jun/04/C-sharp.currency
// set currency format
string curCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
System.Globalization.NumberFormatInfo currencyFormat = new System.Globalization.CultureInfo(curCulture).NumberFormat;
currencyFormat.CurrencyNegativePattern = 1;
number.ToString("c", currencyFormat);
// or string.Format(currencyFormat, "{0:c}", number);