.net - C#, Skipping Console.ReadLine(); Console.Read(); while in loop -
If I run my code and insert the correct value for the first time, then it does the job and it works, But if I input incorrectly, allow loop to spin the second time, it leaves the path = console. Readline ();
but it does not leave the j = (char) console. Read ();
The same thing continues through the rest of the code.
{Console.WriteLine ("Insert path:"); Path = console. Readline (); Temp1 = checkpath (path); // Check if the inserted value is valid (temp1 == incorrect) {Console.WriteLine ("\ nDo you want to skip this step (default directory will be set to desktop) Y / N"); Jammu = (four) console Read (); If (J. Ecklace ('Y')) J.Aklav ('Y')) {Path = Environment Gatefolder Path (environment specialfolder.com desktoptop); Temp1 = true; }} // User Input wi / wi loop will expire and will end with the route chosen by the user or desktop path; While (! Temp1);
path = console.readlines ();
Skipping if the user fails to insert the correct path. I was looking for solutions since yesterday and I have failed to get the same problem on the web. Link to full code:
The call is not being dropped - The problem is that the console .Read ()
will return only after the user returns - Although it only reads the first letter Consumption , it seems that (when the signal is skipped about) user login Does:
Nfoo
and then brings back ... value of path
next recurrence foo
.
The easiest fix is to change your console. Read ()
call Console.ReadLine ()
and handle the situation where the user uses more than one character.
Comments
Post a Comment