String to decimal conversion: dot separation instead of comma

前端 未结 7 1233
野的像风
野的像风 2020-12-05 01:52

I have a string read from a textbox. It contains a comma for decimal separation.

I have NumberFormatInfo.CurrencyDecimalSeparator set to ,

7条回答
  •  时光取名叫无心
    2020-12-05 02:30

    Instead of replace we can force culture like

    var x = decimal.Parse("18,285", new NumberFormatInfo() { NumberDecimalSeparator = "," });
    

    it will give output 18.285

提交回复
热议问题