我正在做一项工作而且我被困在这里:
我的代码是:
public void AddTransaction(ITransaction transaction)
{
if (((transaction is WithdrawalTransaction) || transaction is FundsTransferTransaction) && GetBalance() < transaction.Amount)
{
throw new DebitException(transaction.Amount);
}
else if ((transaction is WithdrawalTransaction) && (transaction.Amount < -350))
{
throw new DebitException(transaction.Amount);
}
else
{
transactions.Add(transaction.TransactionID, transaction);
}
}
并且我应该给它一个错误框,如果事务超过350,则应该出现错误消息。
请帮助
答案 0 :(得分:0)
不确定这是否是您要做的事情?
if (transaction.Amount > 350
{
throw new ApplicationException("My Error message");
}
OR
if (transaction.Amount > 350)
{
MessageBox.Show("It is more than 350");
}
这不是你应该如何理解这种情况。