/ Published in: C#
Here are some example string formats. As I discover more I will add them here.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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