why Console.Read() giving wrong output in following when used instead of Console.ReadLine() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why Console.Read() giving wrong output in following when used instead of Console.ReadLine()

{ static void Main(string[] args) {Console .WriteLine("count to: "); int x= Convert.ToInt32(Console.ReadLine()); for(int i=0; i<=x; i++) {Console .WriteLine(i); } } }

28th Jul 2016, 5:09 PM
rishab
rishab - avatar
3 Answers
0
this code has been posted by someone else in a question, i just posted it with some changes to ask different question.
28th Jul 2016, 5:14 PM
rishab
rishab - avatar
0
Console.Read() only reads the first character that's you write in the console
28th Jul 2016, 7:53 PM
Tomek Cymes
Tomek Cymes - avatar
0
but then for one digit no. output should be same, but in above case it is not
29th Jul 2016, 3:00 AM
rishab
rishab - avatar