String.Format 格式化数值

 

1.Basic number formatting specifiers:Double 1.68  Int -16800

   示例:{0:c}  Currency  $1.68 -$16,800

       {0:d}  Decimal (Whole number) FormatException  -16800

       {0:e}  Scientific  1.680000e+000  -1.680000e+004

       {0:f}  Fixed point 1.68 -16800.00

       {0:g}  General 1.68 -16800

       {0:n}  Number with commas for thousands 1.68  -16,800

       {0:r}  Round trippable  1.68  FormatException

2.Custom number formatting:

  {0:00.00}  123 => 123.00

  {0:0,0} 1234.3=>123,4

  {0:(#).##} 1234.23=> (1234).23

 

 

 

posted @ 2012-12-04 19:52  sulin  阅读(228)  评论(0)    收藏  举报