Return to Snippet

Revision: 14033
at May 16, 2009 12:05 by stewshack


Initial Code
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

Initial URL

                                

Initial Description
Here are some example string formats. As I discover more I will add them here.

Initial Title
C# String Formats

Initial Tags
format, c

Initial Language
C#