我在textbox里输入负号就提示错误  textbox 代码 是这样写的
a = Convert.ToDouble(textBox1.Text);
     请问为什么啊

解决方案 »

  1.   

    不是   把我输入的转换成double类型
    输入的是数字  有负数  所以。。
    但是输入正数的话 没什么问题   一输入负号就出错
      

  2.   

       
    string str="-12.3";
    double a = Convert.ToDouble(str);
    Console.WriteLine(a);
    我这样都行呀
      

  3.   


                double a = double.Parse( textBox1.Text);
                Console.WriteLine(a);
      

  4.   


                double  a = Convert.ToDouble(textBox1.Text); 
                Console.WriteLine(a);
    上面的CODE 可以啊。你必须把变量a申明为double类型 ,就不会出错误了。
      

  5.   


    public partial class Form1 : Form
        {
            double temp = 0;        public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                try
                {
                    temp = double.Parse(textBox1.Text);
                }
                catch
                {
                    MessageBox.Show("无法转换.");
                    return;
                }
                MessageBox.Show(temp.ToString());
            }
        }