private void button1_Click(object sender, EventArgs e) { Cal cal= new Cal(); //采集数据 cal.Number1 = Convert.ToInt32(txtNumber1.Text.Trim()); cal.Number2 = Convert.ToInt32(txtNumber2.Text.Trim()); if (cboCaozuoFu.SelectedIndex == 0) { MessageBox.Show("请选择一个操作符后再执行计算!"); } else { lblResult.Text = cal.JiSuan(result.Text).ToString(); } }
private void button1_Click(object sender, EventArgs e) { Cal cal = new Cal(); //采集数据 cal.Number1 = Convert.ToInt32(txtNumber1.Text.Trim()); cal.Number2 = int.Parse(txtNumber2.Text.Trim()); if (cboCaozuoFu.SelectedIndex == 0) { MessageBox.Show("请选择一个操作符后再执行计算!"); } else { lblResult.Text = cal.JiSuan(cboCaozuoFu.Text).ToString(); } }