String.Format和log.DebugFormat货币
我使用log4net输出格式化消息。下面的代码String.Format和log.DebugFormat货币
log.DebugFormat("Balance: {0:c} ", balance);
结果
“余额:¤1,000.00”
为什么奇怪字符出现,而不是一个$
回答:
我会想象它是事做您的区域设置。
尝试这样:
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(<your culture setting>); log.DebugFormat("Balance: {0:c} ", balance);
如果这么想的工作,那么你可以随时使用调试器来检查的值:
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat ;
具体检查的值:
ansiCurrencySymbol
为了确保它设置为“$”符号。
您也可以在此维基百科页面位数的:http://en.wikipedia.org/wiki/Currency_%28typography%29
这说明了什么,你所得到的符号。
具体做法是:
The currency sign (¤) is a character used to denote a currency, when the symbol for a particular currency is unavailable. It is particularly common in place of symbols, such as that of the Colón (₡), which are absent from most character sets and fonts.
It can be described as a circle the size of a lowercase character with four short radiating arms at 45° (NE), 135° (NW), 225°, (SW) and 315° (SE). It is slightly raised over the baseline.
It is represented in Unicode, as CURRENCY SIGN (U+00A4). In HTML, the character entity reference ¤ or numeric character reference ¤ may be used.
以上是 String.Format和log.DebugFormat货币 的全部内容, 来源链接: utcz.com/qa/258581.html