How do I format a double to currency rounded to the nearest dollar?
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");
This should do the job:
String.Format("{0:C0}", Convert.ToInt32(numba))
The number after the C
specifies the number of decimal places to include.
I suspect you really want to be using the decimal
type for storing such numbers however.
Console.WriteLine(numba.ToString("C0"));