对于插入textBox2中的数量,此方法正在减小textBox1的值.如果textBox1中没有足够的"钱",则应从textBox3中获取超额金额.最后,方法应该将文本框更新为新值,但只清除textBox2,textBox1和textBox3保持不变.任何人都可以告诉我为什么textBox1.text = Account.toString()不将文本框值赋值给变量值Account并且textBox3.text = Savings.toString()不将文本框值赋值给变量值Savings?
public void Debit(decimal amount)
{
decimal Account = Convert.ToDecimal(textBox1.Text);
decimal Savings = Convert.ToDecimal(textBox3.Text);
if ((Account + Savings) < amount)
if (Overdrawn != null)
Owerdrawn(this, new OverdrawnEventArgs (Account, amount));
else if (Account >= amount)
Account -= amount;
else {
amount -= Account;
Account = 0m;
Savings -= amount;
}
textBox1.Text = Account.ToString();
textBox2.Clear();
textBox3.Text = Savings.ToString();
}
Run Code Online (Sandbox Code Playgroud)