Код C# для разработки калькулятора на базе windows,
in my calculator all operator is functioning properly except the multiply operator. I am unable to find out the reason why it is not working?
Что я уже пробовал:
Пожалуйста, помогите мне решить эту проблему.
Double resultValue = 0; String operationPerformed = ""; bool isOperationPerformed = false; private void button_Click(object sender, EventArgs e) { if ((textBox1.Text == "0") || (isOperationPerformed)) textBox1.Clear(); isOperationPerformed = false; Button button = (Button)sender; if (button.Text == ".") { if (!textBox1.Text.Contains(".")) textBox1.Text = textBox1.Text + button.Text; } else textBox1.Text = textBox1.Text + button.Text; } private void operator_Click(object sender, EventArgs e) { Button button = (Button)sender; if (resultValue != 0) { button28.PerformClick(); operationPerformed = button.Text; resultValue = Double.Parse(textBox1.Text); label1.Text = resultValue + " " + operationPerformed; isOperationPerformed = true; } else { operationPerformed = button.Text; resultValue = Double.Parse(textBox1.Text); label1.Text = resultValue + " " + operationPerformed ; isOperationPerformed = true; } } private void buttonEqual_Click_1(object sender, EventArgs e) { switch (operationPerformed) { case "+": textBox1.Text = (resultValue + Double.Parse(textBox1.Text)).ToString(); break; case "-": textBox1.Text = (resultValue - Double.Parse(textBox1.Text)).ToString(); break; case "*": textBox1.Text = (resultValue * Double.Parse(textBox1.Text)).ToString(); break; case "/": textBox1.Text = (resultValue / Double.Parse(textBox1.Text)).ToString(); break; case "%": textBox1.Text = (resultValue % Double.Parse(textBox1.Text)).ToString(); break; default: break; } resultValue = Double.Parse(textBox1.Text); label1.Text = ""; //textBox1.ReadOnly = true; }
CHill60
Что же он на самом деле делает?