Convert string value to decimal with thousand separator?

前端 未结 4 1633
慢半拍i
慢半拍i 2021-01-23 17:42

This might be a very simple question. Suppose text box show value 10,000.12 when user edits data by mistake he remove first two numbers like ,000.12 and using this textbox in t

4条回答
  •  被撕碎了的回忆
    2021-01-23 18:29

    string str = ",0,100.12;";
    var newstr = Regex.Replace(str,@"[^\d\.]+","");
    decimal d = decimal.Parse(newstr, CultureInfo.InvariantCulture);
    

提交回复
热议问题