Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi I want to Split number into groups of 3 digits in c# this is my code :


C#
fo_1 = int.Parse(TextBox1.Text);
        TextBox1.Text = fo_1.ToString("N", CultureInfo.CreateSpecificCulture("es-ES"));





but this code changes 1000000 to 1.000.000,00 but I want 1.000.000
please help me
thanks.
Posted
Updated 19-Oct-15 5:59am
v2

You are using "N", the standard number format string. Without a precision specifier this uses the default precision which is usually "N2". See Standard Numeric Format Strings[^] for details and then try "N0".

Alan.
 
Share this answer
 
Then do not try to convert it to a culture specific number. Use a general format or create a custom numeric format the does not contain digits after the decimal point. See https://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx[^].
 
Share this answer
 
v2
Comments
rezaeti 19-Oct-15 12:27pm    
thanks richard MacCutchan
C#
fo_1 = int.Parse(TextBox1.Text);
        TextBox1.Text = fo_1.ToString("#,#", CultureInfo.InvariantCulture);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900