服務(wù)熱線
153 8323 9821
|
字符 |
說(shuō)明 |
示例 |
輸出 |
| C | 貨幣 | string.Format("{0:C3}", 2) | $2.000 |
| D | 十進(jìn)制 | string.Format("{0:D3}", 2) | 002 |
| E | 科學(xué)計(jì)數(shù)法 | 1.20E+001 | 1.20E+001 |
| G | 常規(guī) | string.Format("{0:G}", 2) | 2 |
| N | 用分號(hào)隔開(kāi)的數(shù)字 | string.Format("{0:N}", 250000) | 250,000.00 |
| X | 十六進(jìn)制 | string.Format("{0:X000}", 12) | C |
| string.Format("{0:000.000}", 12.2) | 012.200 |
There really isn't any formatting within a strong, beyond it's alignment. Alignment works for any argument being printed in a String.Format call.
| Sample | Generates |
| String.Format("->{1,10}<-", "Hello"); | -> Hello<- |
| String.Format("->{1,-10}<-", "Hello"); | ->Hello <- |
Basic number formatting specifiers:
| Specifier | Type | Format |
Output |
Output |
| c | Currency | {0:c} | $1.42 | -$12,400 |
| d | Decimal (Whole number) | {0:d} |
System. FormatException |
-12400 |
| e | Scientific | {0:e} | 1.420000e+000 | -1.240000e+004 |
| f | Fixed point | {0:f} | 1.42 | -12400.00 |
| g | General |
{
相關(guān)文章
|