Goober
Goober

Reputation: 13508

Number Formatting in Thousands

Help greatly appreciated.

Upvotes: 5

Views: 3090

Answers (4)

Dan Tao
Dan Tao

Reputation: 128317

string formatted = value.ToString("N0");

This divides your number in the manner specified by the current culture (in the case of "en-US," it's a comma per multiple of 1000) and includes no decimal places.

The best place to look for any question regarding formatting numbers in .NET would have to be here:

Standard Numeric Format Strings (MSDN)

And here:

Custom Numeric Format Strings (MSDN)

Upvotes: 5

Phil Lamb
Phil Lamb

Reputation: 1437

double x = 10562.3093;
x.ToString("#,0");

or

String.Format("{0:#,0}", 10562.3093);

Upvotes: 0

dcp
dcp

Reputation: 55434

string.Format("{0:n0}", 10562.3093);

Upvotes: 2

drharris
drharris

Reputation: 11214

String.Format("{0:0,0}", 10562.3093);

I keep this website bookmarked for these purposes: String Formatting in C#

Upvotes: 1

Related Questions