user input, completes given function
Hello im back :)
I am using c# in visual studio. I would like to have a question pop up in the terminal, which day of the advent of code they would like to see, currently on day 2 obviously...
if the user gives a value not 1 or 2, i give an error message and ask again. i have never dont getinput in c# so pls help me out with this. I also dont know how to execute a given method without 25 different if statements, im sure there is a better way
4 Replies
Well, to get input from user, you would use
Console.ReadLine()
To keep repeating that question if the value is invalid, a while
or do..while
loop will be usefulwhat about the 25 if statements alternative
Depends what they would be doing tbh
You could use a switch
Switch statement or switch expression, depends
it would be saving memory for a string[] of the puzzle input, and then call a function, and output the result
switch works perfectly, thanks