private void button17_Click(object sender, EventArgs e) { second = double.Parse(textBox1.Text); double Plus; double Divison; double By; double Minus; // Here ill use a "switch" command for not overusing the "if" instruction. switch (operator1) { case "+": Plus = obj.Plus((first), (second)); textBox1.Text = Plus.ToString(); break; case "*": By = obj3.Multiply((first), (second)); textBox1.Text = By.ToString(); break; case "-": Minus = obj2.Minus((first), (second)); textBox1.Text = Minus.ToString(); break; case "/": Divison = obj4.Divide((first), (second)); textBox1.Text = Divison.ToString(); break; } }
public string generateId(String Q) { string connstr = @"Data Source=DESKTOP-QCAJFHA;Initial Catalog=vanpheng_jewelry;Integrated Security=True"; SqlConnection sqlConn = new SqlConnection(connstr); sqlConn.Open(); comm = new SqlCommand(Q, sqlConn); SqlDataReader dr = comm.ExecuteReader(); dataTable = new DataTable(); while (dr.Read()) { Id = dr[0].ToString(); } dr.Close(); int Plus; try { Plus = Convert.ToInt32(Id) + 1; } catch { Plus = 1; } return(Plus.ToString()); }
private void btnPlus_Click(object sender, EventArgs e) { int Plus; bool C1 = int.TryParse(txtNum1.Text, out Plus); if (C1 == false) { MessageBox.Show("請輸入數字", "Oops!"); return; } bool C2 = int.TryParse(txtNum2.Text, out Plus); if (C2 == false) { MessageBox.Show("請輸入數字", "Oops!"); return; } Plus = int.Parse(txtNum1.Text) + int.Parse(txtNum2.Text); labANS.Text = Plus.ToString(); }
public void PlusToStringTest() { Assert.AreEqual("6+2", p.ToString()); }
public void ToString_IntegerOperand_ReturnsExpected() { var expr = new Plus(new Integer(3)); Assert.AreEqual("+3", expr.ToString()); }