Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string format for numbers or currency?

Tags:

c#

asp.net

vb.net

I need to give comma(,) for every thousends. So I used DataFormatString="${0:#,#}". It is working fine. But when value is 0. It is showing $00. I just want to show only $0.

How can we do that?

like image 516
James123 Avatar asked Dec 01 '10 19:12

James123


2 Answers

DataFormatString = "{0:C0}"

That will format as a currency with 0 decimal places.

DataFormatString = "{0:N0}"

This will format as a number such as 1,000. If you want decimal places then replace the second 0 with however many numbers you want after the decimal.

For example:

DataFormatString = "{0:N4}"

Would format like 1,000.0000

like image 117
Dismissile Avatar answered Oct 10 '22 19:10

Dismissile


Format = "${0:#,0}";

like image 8
The Smallest Avatar answered Oct 10 '22 17:10

The Smallest