这是一个基本的计算器程序 我无法清除文本框。
protected void Button_Click(object sender, Event-args e)
{
if ((Result.Text == "0") || (operation_pressed))
Result.Text = String.Empty;
**//Here it should initialize when a value is 0 or when a operator is Clicked**
** //But the value in text-box is not clear even a operator is clicked**
Button b = (Button)sender;
Result.Text = Result.Text + b.Text;
}
protected void Operator_Click(object sender, Event-args e)
{
Button b = (Button)sender;
operation = b.Text;
value = Double.Parse(Result.Text);
operation_pressed = true;
}
答案 0 :(得分:0)
因为文本清除逻辑放在Button_Click
事件中。你几乎没有办法解决这个问题。
Operator_Click
Method
分隔清算部分,并在设置operation_pressed
值后从两个函数调用。