Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
What is the difference between Console.ReadLine(); and Console.Read();
3 Answers
+ 6
Console.WriteLine("your text"); writes your text and goes to new line, while Console.Write("your text") would stay in the same line, eg:
for(int i=0; i < 5; i++)
{ Console.WriteLine(i); }
gives:
0
1
2
3
4
While:
for (int i = 0; i < 5; i++)
{ Console.Write(i); }
gives:
01234
+ 2
Console.ReadLine() returns everything you typed in the console, while Console.Read() inly the first character
0
is the same explanation valid for Console.WriteLine() and Console.Write()?