string.Format using Thousands Separator

J

jp2msft

I know how to format a string to use decimal places:

Code:
Console.WriteLine(string.Format("$ {0:0.00}", 4));
Output:
$ 4.00

How would I format a string to use the Thousands Separator?

for (int i = 0; i < 1000000; i++) // zero to one million
{
Console.WriteLine(string.Format("$ {0:voodoo}", i));
}

What would I replace "voodoo" with?

Thanks.
 
M

Martin Honnen

jp2msft said:
How would I format a string to use the Thousands Separator?

for (int i = 0; i < 1000000; i++) // zero to one million
{
Console.WriteLine(string.Format("$ {0:voodoo}", i));
}

What would I replace "voodoo" with?

Console.WriteLine("$ {0:#,##0.00}", i);
 

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

Top