Expand|Select|Wrap|Line Numbers
- do
- {
- string input = Console.ReadLine();
- game.getInput(input); //input validation (disregard)
- }
- while (Console.ReadLine().ToLower() != "exit");
Expand|Select|Wrap|Line Numbers
- (Console Starts)
- Console has started! //introduction to program
- >hello //what the user inputs: prints value on next line
- hello
- >hello2 //second input (supposed to print to next line)
- >hello2 //third input is taken and printed normally
- hello2
- >hello3 //fourth input (supposed to print to next line)
It seems that every other input is completely disregarded and tossed out even though the user has input something new. Any idea how to clear the buffer between or set up the loop in a better way to accept user input without this "every other input doesn't work" business?
EDIT: In case it matters, the game.getInput() function returns in all cases.
Thanks,
Themantimes8
FINAL EDIT:
After reviewing Rabbit's tip, I reconstructed the loop to look like this:
Expand|Select|Wrap|Line Numbers
- do
- {
- string input = Console.ReadLine();
- if (String.IsNullOrEmpty(input))
- {
- Console.Out.WriteLine("Invalid Input");
- }
- else if (input == "exit")
- {
- exit = true;
- }
- else
- {
- game.getInput(input);
- }
- }
- while (!exit);