Individual long digits of 3 digits

Is there an easy way to convert 1,000,000 to 1,000,000? Regular expression or string format in asp.net, C #

+6
source share
5 answers

You can use ToString along with a format string and a format provider that uses ".". as a separator of groups and determines that the number should be grouped into 3-digit groups (which does not apply to all cultures):

 int number = 1000000; Console.WriteLine(number.ToString("N0", new NumberFormatInfo() { NumberGroupSizes = new[] { 3 }, NumberGroupSeparator = "." })); 
+10
source share

Using ToString("N") after converting 1,000,000 to 1,000,000. Not sure. although

+4
source share

I think you are asking about culture-specific formatting. This is the Spanish way, for example:

 1000000.ToString("N", CultureInfo.CreateSpecificCulture("es-ES")); 
+4
source share
 1000000.ToString("N0") 
+3
source share

Use ToString with a numeric format string after reading into an integer. I believe that the one you are looking for is "N" and its relatives.

MSDN page about number format strings: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

+2
source share

All Articles