-1

Possible Duplicates:
.NET String.Format() to add commas in thousands place for a number
Add comma to numbers every three digits using C#

I want to create a logic in c# too put the comma after each 3 digit int the any 9 digit number, could any body tel me how can i achieve this?

Like i have the following number 123456789 then i want to form it like 123,456,789.

Community
  • 1
  • 1
NoviceToDotNet
  • 10,387
  • 36
  • 112
  • 166

3 Answers3

1

Call ToString and specify "N" as the format string

pstrjds
  • 16,840
  • 6
  • 52
  • 61
0
var formattedString = string.Format("{0:0,0}", 123456789);
Bala R
  • 107,317
  • 23
  • 199
  • 210
0
double value = 1234567890;
Console.WriteLine(value.ToString("#,#", CultureInfo.InvariantCulture));
naveen
  • 53,448
  • 46
  • 161
  • 251