How to add comma (,) in a string after 3 characters from the right?

I have 32000 i want it to be 32,000
I have 150000 i want it to be 150,000

Can someone help me

Thanks

Hi,

Do you need to add comma just before 3 characters from right or add thousand separator?

yourString ="32000"

The former

yourString.Insert(yourString.Length-3,",")

OR

System.Text.RegularExpressions.Regex.Replace(yourString,"(?=\d{3}$)",",")

The latter (add thousand separator)

Decimal.Parse(yourString).ToString("#,#")

Regards,

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.