✅ I need to put an invalid choice in my program

I need to make the program repeat if they did not input a valid response of yes or no
22 Replies
phaseshift
phaseshift2y ago
Do a loop then
monkeyoohlala
monkeyoohlalaOP2y ago
is there a easier way? do a loop kind of broad how do I do this if response == yes continue to the while loop? what kind of loop do I do?
Angius
Angius2y ago
A while loop, for example
while (input is incorrect)
{
ask for input again
}
while (input is incorrect)
{
ask for input again
}
monkeyoohlala
monkeyoohlalaOP2y ago
else if (Response != "yes" && Response != "no") { Console.WriteLine("Invalid Choice"); break; // right here how do I get it to go back to the beginning of the loop? Console.ReadLine(); } I tried break and continue and it did not work
phaseshift
phaseshift2y ago
Break stops the loop. Continue goes to the top of the loop
Angius
Angius2y ago
Well else if is not a loop
monkeyoohlala
monkeyoohlalaOP2y ago
it is inside a loop
Angius
Angius2y ago
Ah, my bad, seems you already have some loops in that chunk of code Yeah
monkeyoohlala
monkeyoohlalaOP2y ago
the app closes when I put continue
monkeyoohlala
monkeyoohlalaOP2y ago
monkeyoohlala
monkeyoohlalaOP2y ago
what are these errors? the top error I know the other errors
phaseshift
phaseshift2y ago
Style rule messages. Not errors
monkeyoohlala
monkeyoohlalaOP2y ago
what is top one
phaseshift
phaseshift2y ago
Self explanatory
monkeyoohlala
monkeyoohlalaOP2y ago
I take out the string[] args?
phaseshift
phaseshift2y ago
Yeah, that's what it's saying
monkeyoohlala
monkeyoohlalaOP2y ago
should I be using switch instead of loop and if statements?
phaseshift
phaseshift2y ago
Switch doesn't loop If doesn't loop
monkeyoohlala
monkeyoohlalaOP2y ago
should I be using switch instead of if is what I meant
phaseshift
phaseshift2y ago
A lot of the time they're interchangeable
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server