I'm new to this field and I'm very confused: what is the real difference between Console.Read()
and Console.ReadLine()
?
For example, when you use the Console. ReadLine() to input the a string "hello", the program maybe exit and you would not see the output "You input is hello". If you use Console. ReadKey(), the program will wait and would not exit.
Your answer The read() will read the whole file at once and then print out the first characters that take up as many bytes as you specify in the parenthesis versus the readline() that will read and print out only the first characters that take up as many bytes as you specify in the parenthesis.
The Console. Read() method in C# is used to read the next character from the standard input stream.
The only difference between the Write() and WriteLine() is that Console. Write is used to print data without printing the new line, while Console. WriteLine is used to print data along with printing the new line.
Console.Read()
reads only the next character from standard input, and Console.ReadLine()
reads the next line of characters from the standard input stream.
Standard input in case of Console Application is input from the user typed words in console UI of your application. Try to create it by Visual studio, and see by yourself.
These are the methods of system.console
(There are more system.console methods like write() and writeline() as well which are used to write in command line, behaving similarly as read() and readline() methods)
This was clearly described with examples in the MSDN documentation (links are included above).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With