C# why is it skipping my console.readline()? -


The program is working properly, but for some reason, for the second time, this is the console skipping. ) Immediately I participated fully through the debug and confirmed that this is not a loop problem because it is actually entering the law, it displays the written line, leaving the readline and leaving it completely That is, he returned a blank and removed the main () what enemy? any idea?

Here is the code.

  using the system; Using System.Collections; Using System.Collections.Generic; Using System.Linq; Using System.Text; Namespace LAB4B {class program {static zero main (string [] args) {string inString; ArrayList = New Array List (); DisplayInfo (); GetInput (outside inString); Do {GetTranslation (inString, translatedPhrase); Performance (sign, translated phrase); GetInput (outside inString); } While (inString! = ""); } Fixed Zero DisplayInfo () {Console.WriteLine ("*** You will be asked to enter the string of ***"); Console.light line ("*** words string will be converted to"% "); console.lightline (" *** pig latin and display results. ***) "; console.light line (" ** Enter the string you want. ");} Fixed zero GetInput (string out word) {Console.Write (" \ n \ nENTER to a group of words or ENTER to quit: "); word = console .Readline ();} Fixed zero GetTranslation (string original language, translated into array list) {int wordLength; str [] SplitPhrase = Original language Sample (); Foreign words (language divided into string words) {wordLength = word.Length; translated; add (word .Substring (1, word length - 1) + word .Substring ( 0, 1) + "AE");}} Fixed zero performance (string origin string, error string translated strings) {Console.WriteLine ("\ n \ n Basic word: {0}", original string); "New word:"); Foreign language (string word in translated string) {Console.Write ("{0}", word);} console. Read ();}}}}  

This is due to your console. Read () in the DisplayResults method. It usually reads only one character if you press enter (which is actually a combination of 2 characters - the carries return and line feed) on the console. Read () This only gets the Carriage Return character, and the line feed gets in your next console reading method - console. GetInput () method in readline () . Since line feed character is a liner entry character, because console.readlines () reads it as a line.


Comments