2
A
回答
2
這意味着資金有千個分隔符(,),如果在小數值將小數後四捨五入到兩位數,如果有僅十進制值(0.256)這將是(0.27)
decimal money=12341257 //output= 12,341,257
decimal money=1257 //output= 1,257
decimal money=1257.25 //output= 1,257.25
decimal money=1257.2468 //output= 1,257.25
decimal money=.50 //output= 0.50
decimal money=.759 //output= 0.76
說明:
"{0:#,0.##}"
#,0 //means that , as thousand seperator
0.## //means that 0 is placed before if only decimal values as .56 to 0.56
0.## //means if contains decimal then only display 2 digits after decimal
0.00 //means 2 digits after decimal must be displayed whether or not money contains decimal value
3
我沒有我的開發系統,我,所以我無法驗證我要告訴你,但這裏是我的解釋:
格式部分是「#,## 0」。我認爲「#,0」部分指定一個逗號應該分隔數千(例如1,000,000)。 「。##」指定小數點後的位數。我原以爲你需要「.00」強制兩位數(這對貨幣來說是正常的)。但我期望你至少要在小數點後舍入到兩位數。
你試過了嗎?
0
我相信這是一種帶千位分隔符的貨幣格式,如果包含小數值,只顯示小數點後的前2位。
這裏自定義格式字符串的很好的概述:
http://blog.stevex.net/string-formatting-in-csharp/
此鏈接包含更多細節,包括千位分隔符的更自由的形式與「」字符的描述:
http://msdn.microsoft.com/en-us/library/0c899ak8%28v=vs.71%29.aspx
0
基本上,這將格式設置爲具有千位分隔符和2位小數位。根據Microsoft文檔,數字將被舍入到正確的小數位數。
這是自定義數字格式字符串一個很好的資源: http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
相關問題
- 1. 的String.Format問題
- 2. 的String.Format問題
- 3. String.Format問題
- 4. String.Format()問題
- 5. 的String.Format在.NET
- 6. String.Format和TimeSpan問題
- 7. String.Format輸出問題
- 8. String.Format針對string.Format。任何問題?
- 9. 的String.Format VS int.ToString的問候iCustomFormatter問題
- 10. Java相當於.NET的String.Format
- 11. C#的String.Format和SpriteBatch.DrawString間距問題
- 12. 另一個.Net使用Java WSDL問題
- 13. 又一個.NET XPath謂詞問題
- 14. .NET鎖 - 兩個問題
- 15. 用String.Format添加一個「 - 」VB.Net
- 16. JavaScript:格式編號/貨幣W /問候文化像.NET的String.Format()?
- 17. .NET的String.Format相當於在Java中
- 18. 在Java中等效的String.Format(.NET)?
- 19. .NET多個表單在一個頁面上的問題
- 20. 問題:在.NET
- 21. .NET vScrollBar問題
- 22. .Net Mutex問題
- 23. Hard .net問題
- 24. .NET SoundPlayer問題
- 25. .NET - System.Timers.Timer問題
- 26. .net tracelistener問題
- 27. .NET ChatRemoting問題
- 28. .NET CreateEventSource問題
- 29. 問題在.NET
- 30. .Net DateTime.Subtract問題
請參閱C#中的字符串格式:http://blog.stevex.net/string-formatting-in-csharp/ – 2010-12-13 04:19:02