2008年12月30日 星期二

數值格式字串

Console.WriteLine(

string.Format("{0:#,0.00;(#,0.00);-}", -1234.56));

// (1,234.56)

Console.WriteLine(

string.Format("{0:#,0.00;(#,0.00);-}", 1234.56));

// 1,234.56

Console.WriteLine(

string.Format("{0:#,0.00;(#,0.00);-}", 0));

// -


原文

MSDN 自訂數值格式字串