How do I convert string to Indian Money format?

前端 未结 4 840
感动是毒
感动是毒 2020-12-01 22:13

I am trying to convert string to India Money format like if input is \"1234567\" then output should come as \"12,34,567\"

I have written following code but its not g

4条回答
  •  萌比男神i
    2020-12-01 22:24

    String.Format("0:C0") for no decimal places.

    As per my comment above you can achieve what you desire by cloning a numberformatinfo and set the currency symbol property to empty string

    Example can be found here - look down the bottom of the page

    EDIT: Here is the above linked post formatted for your question:

    var cultureInfo = new CultureInfo("hi-IN")
    var numberFormatInfo = (NumberFormatInfo)cultureInfo.NumberFormat.Clone();
    numberFormatInfo.CurrencySymbol = "";
    
    var price = 1234567;
    var formattedPrice = price.ToString("0:C0", numberFormatInfo); // Output: "12,34,567"
    

提交回复
热议问题