3

Possible Duplicate:
.NET String.Format() to add commas in thousands place for a number

Hello

I have money value like that

    12345
    123456
    1234567
    1234567,89

What i want is formated like this.

12,345
123,456
1,234,567
1,234,567, 89

How can i do that with String.Format ?

2

2 Answers 2

8
String.Format("{0:c}");

This will format your number like currency based on the client's locale configuration.

If your client's locale is in Europe it'll come out $12.134,45 because that's how it's done over there.

This is the preferred method of currency formatting, if you want to specifically just get the comma's and no $ you'll probably have to do it using "{0:#,##0}" or something along those lines.

Sign up to request clarification or add additional context in comments.

1 Comment

+1. Usual reminder - there are cultures that don't have groups separator too. If you explicitly need format with , as "groups separator" pass specific culture (i.e. "en-US" to String.Format).
1

Cool new way...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.