How can i make a user input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i make a user input

im trying to use all stuff i have gone throught to make a simple program to learn more but im stuck, since if i try to use the user input people would be able to type in letters and i only want them to be able to put in numbers from 1-3. to keep it simple and i still want to keep the switch cource in my program this is my first go on the program. http://www.sololearn.com/app/csharp/playground/cc8DL50PtG7h/

6th Nov 2016, 10:57 PM
Jack Sparrow
Jack Sparrow - avatar
3 Answers
0
string input; while (true) { input = Console.ReadLine(); if (input == "1" or input == "2" or input == "3") { break; } Console.WriteLine("Pleas enter a valid input"); } Then you can cast input to integer if you need to.
7th Nov 2016, 12:47 AM
Jax
Jax - avatar
0
thank you so much
7th Nov 2016, 12:48 AM
Jack Sparrow
Jack Sparrow - avatar
0
you are welcome ^_^
7th Nov 2016, 12:51 AM
Jax
Jax - avatar