Error Sample:
//假設textBox1.Text等於1.5 textBox1.Text = "1.5"; //轉換textBox1.Text成Double double a = Convert.ToDouble(textBox1.Text); //印出結果es錯誤, 語系=en, a=1.5;語系=es, a=15 Response.Write(a.Tostring());
Good Sample:
//假設textBox1.Text等於1.5 textBox1.Text = "1.5"; //轉換textBox1.Text成Double並加上區域文化 double b = Convert.ToDouble(textBox1.Text, System.Globalization.CultureInfo.InvariantCulture) //印出結果es正確,語系=en, b=1.5;語系=es, b=1.5 Response.Write(b.Tostring());
沒有留言:
張貼留言