Home > Development > C# Two Decimal Places Format String

C# Two Decimal Places Format String


Needed this today. I never remember format strings.

String.Format("{0:0.00}", 123.4567);      // "123.46"
String.Format("{0:0.00}", 123.4);         // "123.40"
String.Format("{0:0.00}", 123.0);         // "123.00"

Hope this helps.
Blair..

Categories: Development Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment