views:

2521

answers:

2

I want to format an int as a currency in C#, but with no fractions. For example, 100000 should be "$100,000", instead of "$100,000.00" (which 100000.ToString("C") gives).

I know I can do this with 100000.ToString("$#,0"), but that's $-specific. Is there a way to do it with the currency ("C") formatter?

+7  A: 

Use format "C0".

John
A: 

Not sure if there's a simpler way but this works:

int i = 123456789;
string h = String.Format("{0:$#,#.}", i);
Console.WriteLine(h);

EDIT: {0:c0} is simpler

Mitch Wheat