Difference Between Console.Write(), Console.WriteLine() and Console.Read()
The Write () method outputs one or more values to the screen without a new line character.
The WriteLine() always appends a new line character to the end of the string. this means any subsequent output will start on a new line.
- ReadKey (returns a character): reads only one single character from the standard input stream. Usually used when you're giving options to the user in the console to select from, such as select A, B or C. Another prominent example, Press Y or n to continue.
- ReadLine (returns a string): reads only single line from the standard input stream. As an example, it can be used to ask the user enter their name or age.
- Read (returns an int): reads only one single character from the standard input stream. Similar to ReadKey except that it returns an integer.
Comments
Post a Comment