回 帖 发 新 帖 刷新版面

主题:C#计算器混合运算的代码

private void button12_Click(object sender, EventArgs e)
        {
            switch (S1)
            {
                case 1:
                    btn2=btn1 + Convert.ToDouble(textBox1.Text);
                    textBox1.Text=btn2.ToString();
                    break;
                case 2:
                    if (btn1 > Convert.ToDouble(textBox1.Text))
                    {
                        btn2 = btn1 - Convert.ToDouble(textBox1.Text);
                        textBox1.Text = btn2.ToString();
                    }
                    else
                    {
                        btn2 = Convert.ToDouble(textBox1.Text) - btn1;
                        textBox1.Text =  btn2.ToString()+"-";
                    }
                    break;
                case 3:
                    btn2 = btn1 / Convert.ToDouble(textBox1.Text);
                    textBox1.Text = btn2.ToString();
                    break;
                case 4:
                    btn2 = btn1 * Convert.ToDouble(textBox1.Text);
                    textBox1.Text = btn2.ToString();
                    break;
怎么才能实现混合运算

回复列表 (共1个回复)

沙发

11111

我来回复

您尚未登录,请登录后再回复。点此登录或注册