+ 1

Why is my loop running more than it should

Just a little exercise with a do while loop. do { Console.WriteLine("Press a key"); input = Console.Read(); ch = Convert.ToChar(input); }while(ch != 'N'); if I have input N, everything is good if I have input XXN, I see press key 5 times instead of 3 times Why ? I work in the playground https://code.sololearn.com/cXzZUD8AV6oe

22nd Sep 2017, 8:42 PM
sneeze
sneeze - avatar
5 Respostas
+ 3
Hmm it works fine to me and I got "Press a key" × 3 with input "XXN" in Code Playground via my phone. 😶
23rd Sep 2017, 12:26 AM
Zephyr Koo
Zephyr Koo - avatar
+ 2
that problem is in playground. If you go to a real compiler you shouldnt to have that problem
22nd Sep 2017, 9:21 PM
Daniel
Daniel - avatar
+ 1
It is for inputs in loop
23rd Sep 2017, 12:30 AM
Daniel
Daniel - avatar