c# - Why does this not print everything on the same line? -


watch video (https://www.youtube.com/watch?v=bfdp3_tf7ks) 2:47 understand predicament.

it supposed print backwards on same line.

namespace understandingarrays {     class program     {         static void main(string[] args)         {            string zig = "you can want out of life if "             + "you enough people want out of life.";          char[] chararray = zig.tochararray();         array.reverse(chararray);          foreach (char zigchar in chararray)         {             console.write(zigchar);                 console.readline();          }     } } 

readline() blocks until program reads '\n', program prints out single character , waits hit enter (which causes terminal go next line). because of this, end getting single character on each line.

you use console.readkey(boolean) (and not display) next keystroke.

you can move console.readline() outside foreach loop, prints , waits newline.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -