我是 C# 新手。我正在尝试制作计算器,但出现以下错误:
输入字符串的格式不正确。
这是代码的摘要:
double num1, num2, result;
private void button14_Click(object sender, EventArgs e)
{
num1 = Convert.ToDouble(textBox1.Text);
textBox1.Text = String.Empty;
num2 = double.Parse(textBox1.Text); **//ERROR OCCURED HERE**
result = num1 - num2;
}
private void button13_Click(object sender, EventArgs e)
{
num1 = Convert.ToDouble(textBox1.Text);
textBox1.Text = String.Empty;
num2 = System.Double.Parse(textBox1.Text); **//ERROR OCCURED HERE**
result = num1 + num2;
}
如何将字符串转换为双精度类型?