How do I format a double to currency rounded to the nearst dollar?

Spread the love

Question Description

Right now I have

double numba = 5212.6312
String.Format("{0:C}", Convert.ToInt32(numba) )

This will give me

$5,213.00

but I don’t want the “.00”.

I know I can just drop the last three characters of the string every time to achieve the effect, but seems like there should be an easier way.

Practice As Follows

First – don’t keep currency in a double – use a decimal instead. Every time. Then use “C0” as the format specifier:

decimal numba = 5212.6312M;
string s = numba.ToString("C0");

Leave a Comment