c#: how to force trailing zero in numeric format string?

P a u l picture P a u l · Apr 25, 2009 · Viewed 34.7k times · Source

I need to display float as

1.00
1.50
1.55
1.60

The following is what I see using f2 format.

1.
1.5
1.55
1.6

Is there a way to force the trailing 0 to appear?

(I'm using a DevExpress SpinEdit control and trying to set the display and edit format.)

Answer

LukeH picture LukeH · Apr 25, 2009
yourNumber.ToString("N2");