string sText = "111,111,111";
int i;
i = Int32.Parse(sText, NumberStyles.AllowThousands);
Showing posts with label Thousand separator. Show all posts
Showing posts with label Thousand separator. Show all posts
2009/05/27
C#- Thousand separator
To add thousand separator to your number, you could do this:
Convert.ToDecimal(yourNumber.Text.ToString()).ToString("N2")
or
Convert.ToDecimal(yourNumber.Text.ToString()).ToString("N4")
where N2 = 2 decimal place and N4 = 4 decimal place.
if you don't want any decimal place you can try this:
Convert.ToInt32(yourNumber.Text.ToString()).ToString("N0")
Convert.ToDecimal(yourNumber.Text.ToString()).ToString("N2")
or
Convert.ToDecimal(yourNumber.Text.ToString()).ToString("N4")
where N2 = 2 decimal place and N4 = 4 decimal place.
if you don't want any decimal place you can try this:
Convert.ToInt32(yourNumber.Text.ToString()).ToString("N0")
Subscribe to:
Posts (Atom)