-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
  • 9,889
  • 32
  • 106
  • 163

3 Answers3

1

Call ToString and specify "N" as the format string

pstrjds
  • 16,002
  • 6
  • 49
  • 60
0
var formattedString = string.Format("{0:0,0}", 123456789);
Bala R
  • 104,615
  • 23
  • 192
  • 207
0
double value = 1234567890;
Console.WriteLine(value.ToString("#,#", CultureInfo.InvariantCulture));
naveen
  • 51,042
  • 46
  • 158
  • 241