In C#, to take input from the standard input device, the following method are used – Console.Read() and Console.ReadLine() method. Console is a predefined class of System namespace. While Read() and ReadLine() both are the Console Class methods.
The only difference between the Read() and ReadLine() is that Console.Read is used to read only single character from the standard output device, while Console.ReadLine is used to read a line or string from the standard output device.
Program 1: Example of Console.Read() in C#.
C#
// C# program to show the difference // between Console.Read() and // Console.ReadLine() method using System; public class GFG{ static void Main(string[] args) { // use of Read() method Console.Write(Convert.ToChar(Console.Read())); Console.Write(Convert.ToChar(Console.Read())); Console.Write(Convert.ToChar(Console.Read())); } } |
Input:
Geeks
Output:
Gee
Program 2: Example of Console.ReadLine() in C#.
C#
// C# program to show the difference // between Console.Read() and // Console.ReadLine() method using System; public class GFG{ static void Main(string[] args) { // use of ReadLine() method Console.Write(Console.ReadLine()); Console.Write(Console.ReadLine()); Console.Write(Console.ReadLine()); } } |
Input:
Geeks For Geeks
Output:
GeeksForGeeks
In the above code, program 1 shows that it will read only single character and program 2 shows it will read string until new line character is not found.
Recommended Posts:
- Difference between C++ and Go
- Difference between LAN, MAN and WAN
- Difference between GSM and LTE
- Difference Between DAS and SAN
- Difference between DFD and ERD
- Difference between GCC and G++
- Difference Between GIT and SVN
- Difference between MAN and WAN
- Difference between TCP and RTP
- Difference Between Blu-Ray and DVD
- Difference between PNG and GIF
- Difference between SDN and NFV
- Difference Between SMO and SEO
- Difference between IoT and M2M
- Difference between ANN, CNN and RNN
- Difference between DFA and NFA
- Difference between LAN and WAN
- Difference between RPC and RMI
- Difference between DDR 5 and DDR 3
- Difference between PCA VS t-SNE
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

