How do I parse a string with a decimal point to a double?

前端 未结 19 1287
孤街浪徒
孤街浪徒 2020-11-22 06:47

I want to parse a string like \"3.5\" to a double. However,

double.Parse(\"3.5\") 

yields 35 and

double.Pars         


        
相关标签:
19条回答
  • 2020-11-22 07:26
    System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CurrentCulture;
    
    string _pos = dblstr.Replace(".",
        ci.NumberFormat.NumberDecimalSeparator).Replace(",",
            ci.NumberFormat.NumberDecimalSeparator);
    
    double _dbl = double.Parse(_pos);
    
    0 讨论(0)
提交回复
热议问题