Response.Write(String.Format("{0:#,###.##}",0)); returns empty string

  • Thread starter Thread starter Von Shean
  • Start date Start date
V

Von Shean

I use the following code to format the numbers to have commas. But in case
when input is zero it returns an empty string....any ideas?

String.Format("{0:#,###.##}",dblNum);
 
Von said:
I use the following code to format the numbers to have commas. But in case
when input is zero it returns an empty string....any ideas?

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

You want something like:

String.Format("{0:#,##0.00}",dblNum);

depending on whether or not you always want to display 2 digits after
the decimal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top