I was working on this code snippet
private void calculateButton_Click(object sender, EventArgs e) { int amount; if (int.TryParse(amountText
Store the value of TryParse result, then check the amount in the same if statement, like so:
TryParse
amount
if
boolean parseResult = int.TryParse(amountTextBox.Text, out amount) if (parseResult && amount >= 0) { //.... } else { MessageBox.Show("Invalid amount"); }