0
Do While String Question
This is not working for some reason. Please help! //Do loop to make sure input is 1, 2 or 3 only do { //Opening input question. Console.WriteLine("Type a number: rock(1) paper(2) or scissors(3)"); //Sets string variable based on user input choice = Convert.ToString(Console.ReadLine()); } while (choice != "1" || choice != "2" || choice != "3"); Console.WriteLine("shipoopy");
4 Answers
+ 6
choice is not initialized. Write it as:
string choice = Console.ReadLine();
ReadLine() always returns a string, so no need to convert.
Use && instead of || for the condition, otherwise you'll stay in the loop even with the right input.
+ 4
You didn't even set something :
int choice = 0;
Place it before the while loop.
In the while loop :
choice = Console.ReadLine();
+ 2
I had already declared the CHOICE variable. Using && instead of || made it work!
+ 1
see this code sample [https://code.sololearn.com/cqRuTyhl2a78]