Wednesday, March 28, 2012

String.Format("{0:#.##}", 19.9)

How come the above comes out as 19.9 and not 19.90.as intended? Is there a way to add trailing zeros to the format? Thanks.

Hi,

Could you post a little bit more code?

My understanding is you can useSubstring()method to deal that. For example.

string str = 19.90;

Response.Write(str);

str = str.Substring(0,4);

Response.Write(str);

Result: 19.90

19.9

Try that.

0 comments:

Post a Comment