Thursday, 8 July 2010

C# STRING FORMATS

  1. int MySalary = 123456;
  2. String.Format( "{0:C}", MySalary ); // $123,456.00
  3. String.Format( "{0:D}", MySalary ); // 123456
  4. String.Format( "{0:E}", MySalary ); // 1.234560E+005
  5. String.Format( "{0:F}", MySalary ); // 123456.00
  6. String.Format( "{0:G}", MySalary ); // 123456
  7. String.Format( "{0:N}", MySalary ); // 123,456.00
  8. String.Format( "{0:X}", MySalary ); // 1E240
  9. String.Format( "{0:#%}", MySalary ); // 12345600%
  10. String.Format( "{0:#,###}", MySalary ); // 123,456
  11. String.Format( "{0:#,###.00}", MySalary ); // 123,456.00
  12. String.Format( "{0:#,###.##}", MySalary ); // 123,456
  13. String.Format( "{0:'$'#,###.00}", MySalary ); // $123,456.00
  14. String.Format( "{0:#,###' lbs'}", MySalary ); // 123,456 lbs
  15. MySalary = -123456;
  16. String.Format( "{0:#0}", MySalary ); // -123456
  17. String.Format( "{0:#0;(#0)}", MySalary ); // (123456)
  18. DateTime.Now.ToString( "yyyy-MM-ddTHH:MM:ss" ); // XSD:DateTime format 2009-05-16T10:05:46

No comments:

Post a Comment