basic card game, have a switch statement in a while loop. case is card number selected by user input, then replaced. that part is working fine. but testing the default statement (any number not 0-5), and it goes into an infinite loop of the default console.writeline there and I'm not sure why its not breaking. in previous switches nested in while loops its worked for me but ive never had this infinite loop issue on previous defaults before. any help/tips?
int userInput;
string userString;
Console.WriteLine("Would you like to replace a card?");
Console.WriteLine("Select which card you would like to replace, 1-5. Enter 0 to skip");
userString = Console.ReadLine();
int.TryParse(userString, out userInput);
while (userInput != 0)
{
switch (userInput)
{
case 1:
userInput--;
userHand[userInput] = cardDeck.GetOneCard();
break;
case 2:
userInput--;
userHand[userInput] = cardDeck.GetOneCard();
break;
case 3:
userInput--;
userHand[userInput] = cardDeck.GetOneCard();
break;
case 4:
userInput--;
userHand[userInput] = cardDeck.GetOneCard();
break;
case 5:
userInput--;
userHand[userInput] = cardDeck.GetOneCard();
break;
default:
Console.WriteLine("Incorrect input, try again");
break;
}
}