C# 如何修复子操作、乘法和除法C的代码#

C# 如何修复子操作、乘法和除法C的代码#,c#,C#,我在做一个计算器。当我输入两个数字并按下equal键时,我创建了代码,它完成了减法、加法、乘法和除法等工作。请帮助我制作连续减法、乘法和除法的代码,而不必按等号进行加法。我已经完成了代码。请帮助我制作按钮。我将包括下面的全部代码,请帮助我修复它 namespace WindowsFormsApp1 { public partial class Windows10Calcoo : Form { string Input, NumStore1, NumStore2 =

我在做一个计算器。当我输入两个数字并按下equal键时,我创建了代码,它完成了减法、加法、乘法和除法等工作。请帮助我制作连续减法、乘法和除法的代码,而不必按等号进行加法。我已经完成了代码。请帮助我制作按钮。我将包括下面的全部代码,请帮助我修复它

namespace WindowsFormsApp1
{
    public partial class Windows10Calcoo : Form
    {
        string Input, NumStore1, NumStore2 = string.Empty ;
        char Operation;
        double Answ;
        public Windows10Calcoo()
        {
            InitializeComponent();
        }

    private void PlusBtn_Click(object sender, EventArgs e)
    {

        //Creating + and Storing Num1
        NumStore1 = Input;
        Operation = '+';
        Input = string.Empty;

        //Storing Number 2
        NumStore2 = Input;
        double num1, num2;
        double.TryParse(NumStore1, out num1);
        double.TryParse(NumStore2, out num2);

        // Adding Code
        Answ += num1 + num2;
        textBox1.Text = Answ.ToString();



    }

    private void SubBtn_Click(object sender, EventArgs e)
    {
        NumStore1 = Input;
        Operation = '-';
        Input = string.Empty;

        //Storing Number 2
        NumStore2 = Input;
        double num1, num2;
        double.TryParse(NumStore1, out num1);
        double.TryParse(NumStore2, out num2);

        // Adding Code
        Answ += num1 - num2 ;
        textBox1.Text = Answ.ToString();
    }

    private void DivideBtn_Click(object sender, EventArgs e)
    {
        NumStore1 = Input;
        Operation = '/';
        Input = string.Empty;

    }

    private void MultiBtn_Click(object sender, EventArgs e)
    {
        NumStore1 = Input;
        Operation = '*';
        Input = string.Empty;

    }

    private void BackSpaceBtn_Click(object sender, EventArgs e)
    {
        int textlength = textBox1.Text.Length;
        textBox1.Text = textBox1.Text.Substring(0, textlength - 1);
    }

    private void OneBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "1";
        this.textBox1.Text += Input;
    }

    private void TwoBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "2";
        this.textBox1.Text += Input;
    }

    private void ThreeBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "3";
        this.textBox1.Text += Input;
    }

    private void FourBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "4";
        this.textBox1.Text += Input;
    }

    private void FiveBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "5";
        this.textBox1.Text += Input;
    }

    private void SixBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "6";
        this.textBox1.Text += Input;
    }

    private void SevenBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "7";
        this.textBox1.Text += Input;
    }

    private void EightBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "8";
        this.textBox1.Text += Input;
    }

    private void NineBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "9";
        this.textBox1.Text += Input;
    }

    private void ZeroBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += "0";
        this.textBox1.Text += Input;
    }

    private void DecimalBtn_Click(object sender, EventArgs e)
    {
        this.textBox1.Text = "";
        Input += ".";
        this.textBox1.Text += Input;
    }

    private void ClearBtn_Click(object sender, EventArgs e)
    {
        Input += "C";

        this.textBox1.Text = "";
        this.Input = string.Empty;
        this.NumStore1 = string.Empty;
        this.NumStore2 = string.Empty;
        Answ = 0;

    }

    private void EqualBtn_Click(object sender, EventArgs e)
    {

        NumStore2 = Input;
        double num1, num2;
        double.TryParse(NumStore1, out num1);
        double.TryParse(NumStore2, out num2);


        this.textBox1.Text = "";
        this.Input = string.Empty;
        this.NumStore1 = string.Empty;
        this.NumStore2 = string.Empty;

        if (Operation == '+')
        {
            Answ = num1 + num2;
            textBox1.Text = Answ.ToString();
        }
        else if (Operation == '-')
        {
            Answ = num1 - num2;
            textBox1.Text = Answ.ToString();
        }
        else if (Operation == '*')
        {
            Answ = num1 * num2;
            textBox1.Text = Answ.ToString();
        }
        else if (Operation == '/')
        {
            if (num2 != 0)
            {
                Answ = num1 / num2;
                textBox1.Text = Answ.ToString();
            }
            else
            {
                textBox1.Text = "DIV/Zero!";
            }
        }

    }
    private void Windows10Calcoo_Load(object sender, EventArgs e)
    {

    }
}
}

对于减法按钮,当我使用[Answ+=num1-num2;]时,它的不减法会继续加,如果我使用[Answ-=num1-num2;]它的加是负的。

它的加是负的,不是吗?您想只显示这两个数字上的操作还是保留操作的历史记录?在这种情况下,如果
num1
大于
num2
Answ
将增加。不,我的意思是“100-50=50”,但我得到的答案是“-50”,如果我用“5”减去它,它将变为“+55”,然后再次用“5”减去它,它将变为“-50”,谢谢玩具回复@Guy