开发者

place a comma after each 3 digit in a 9 digit numbe in c#? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

开发者_Python百科 .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.


Call ToString and specify "N" as the format string


var formattedString = string.Format("{0:0,0}", 123456789);


double value = 1234567890;
Console.WriteLine(value.ToString("#,#", CultureInfo.InvariantCulture));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜