我使用log4net輸出格式化消息。下面的代碼String.Format和log.DebugFormat貨幣
log.DebugFormat("Balance: {0:c} ", balance);
結果
「餘額:¤1,000.00」
爲什麼奇怪字符出現,而不是一個$
我使用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.
試過了,得到了同樣的結果 – Striker 2009-08-26 20:09:14
你檢查你的計算機上的區域設置? – Stephan 2009-08-26 19:53:16
你在哪裏登錄? – 2009-08-26 19:54:18
我真的認爲它與log4net有關,因爲它按預期工作。 log.Debug(String.Format(「Balance:{0:C}」,balance)); – Striker 2009-08-26 20:18:26