double a = double.Parse( this.textBox1.Text); double b = double.Parse(this.textBox2.Text); double c =0; switch (this.comboBox1.Text) { case "+": c = a + b; break; case "-": c = a - b; break; case "*": c = a * b; break; case "/": c = a / b; break; default: c =0; break; } MessageBox.Show(c.ToString());
double num1 = 0; double num2 = 0; if (!double.TryParse(this.textBox1.Text, out num1)) { MessageBox.Show("s"); return; } if (!double.TryParse(this.textBox2.Text, out num2)) { MessageBox.Show("s"); return; } this.label1.Text = (num1 + num2).ToString();
时间: 2024-10-14 19:00:02