public void TopUp(int amount) { _balance += amount; var args = new WalletEventArgs($"The wallet was topped up on {amount} of money", amount); ToppedUp?.Invoke(this, args); // null condition operator }
public void Withdraw(int amount) { if (_balance < amount) { var args = new WalletEventArgs($"Not enough money on wallet's balance", amount); Withdrawn?.Invoke(this, args); } else { _balance -= amount; var args = new WalletEventArgs($"{amount} of money was withdrawned from the wallet", amount); Withdrawn?.Invoke(this, args); } }