本代码列举了一些字符串格式化的方法,非常实用
int MySalary = 123456; String.Format( "{0:C}", MySalary ); // $123,456.00 String.Format( "{0:D}", MySalary ); // 123456 String.Format( "{0:E}", MySalary ); // 1.234560E+005 String.Format( "{0:F}", MySalary ); // 123456.00 String.Format( "{0:G}", MySalary ); // 123456 String.Format( "{0:N}", MySalary ); // 123,456.00 String.Format( "{0:X}", MySalary ); // 1E240 String.Format( "{0:#%}", MySalary ); // 12345600% String.Format( "{0:#,###}", MySalary ); // 123,456 String.Format( "{0:#,###.00}", MySalary ); // 123,456.00 String.Format( "{0:#,###.##}", MySalary ); // 123,456 String.Format( "{0:'$'#,###.00}", MySalary ); // $123,456.00 String.Format( "{0:#,###' lbs'}", MySalary ); // 123,456 lbs MySalary = -123456; String.Format( "{0:#0}", MySalary ); // -123456 String.Format( "{0:#0;(#0)}", MySalary ); // (123456) DateTime.Now.ToString( "yyyy-MM-ddTHH:MM:ss" ); // XSD:DateTime format 2009-05-16T10:05:46