C# 数学运算符不能应用于类型为';双倍';和';字符串';

C# 数学运算符不能应用于类型为';双倍';和';字符串';,c#,C#,我在equals按钮上出错 private void button25_Click(object sender, EventArgs e) { lblShowOp.Text = ""; switch (operation) { case "+": tb1.Text = (results + Double.Parse(tb1.Text).ToString()); break; case "-":

我在equals按钮上出错

private void button25_Click(object sender, EventArgs e)
{
    lblShowOp.Text = "";
    switch (operation)
    {
        case "+":
            tb1.Text = (results + Double.Parse(tb1.Text).ToString());
            break;
        case "-":
            // operator '-' cannot be applied to operands of type 'double and string'
            tb1.Text = (results - Double.Parse(tb1.Text).ToString());
            break;
        case "*":
            // operator '*' cannot be applied to operands of type 'double and string'
            tb1.Text = (results * Double.Parse(tb1.Text).ToString());
            break;
        case "/":
            // operator '/' cannot be applied to operands of type 'double and string'
            tb1.Text = (results / Double.Parse(tb1.Text).ToString());
            break;
    }
}
Double.Parse(tb1.Text).ToString()将解析为一个数字,然后转换回字符串

根据错误消息,您不能向字符串中添加数字(或乘法、减法等)

你把括号放错地方了。对此进行更改:

tb1.Text = (results + Double.Parse(tb1.Text).ToString());
为此:

tb1.Text = (results + Double.Parse(tb1.Text)).ToString();

其他人也是如此。

在哪一行出现错误?@O.R.Mapper在最后一部分。这里有一条注释显示了错误。@Sayse最后一部分的错误是运算符“-”不能应用于“double and string”类型的操作数。当您提出问题时,您应该尝试创建一个表达式,并展示您自己修复它的努力。@Sayse抱歉,先生。注意!我上周刚加入这里。我希望你能理解。