c# - Displaying typed characters on new line -
may funny question, newbie in c#
class program { static void main(string[] args) { int a; = convert.toint32(console.readline()); console.writeline(a); console.readkey(); } }
i expected after typing character, these character written on new line in console, though these printed on 1 line. wrong?
p.s.
console.writeline("asd"); console.writeline("dsa");
this displayed expected:
asd dsa
every call of console.writeline() method prints new line. example take input , print input single time.
you try instead:
class program { static void main(string[] args) { int a; while(true) { = convert.toint32(console.readline()); console.writeline(a); } } }
edit: included version uses char , console.read() seems more appropriate
class program { static void main(string[] args) { char a; while(true) { = (char)console.read(); console.writeline(a); } } }
Comments
Post a Comment