double.parse怎么用,总出错?

来源:百度知道 编辑:UC知道 时间:2024/06/06 15:07:20
这么一段代码,windows窗口应用程序,VS2005

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

double a=double.parse(this->textBox2->Text);

}

编译总提示error C2062: type 'double' unexpected,是什么原因。
this.textBox2.Text 肯定是字符型的
this.textBox2.Text 不为空,默认已经填上数字了

编译的时候就提示不通过。

Parse是静态型的,不是成员函数,不能使用点操作符。
修正操作符:
double dbl = double::Parse(this->textBox2->Text);

先判断一下textBox2->Text是否为空,不为空再
double a=double.parse(this->textBox2->Text);

你断点执行一下
this.textBox2.Text 获取的是不是一个数字型的