Lesson 10: Reading input
So far the program talked. Now it will listen: Console.ReadLine() reads a line the user types and returns it as a string. You store the answer in a variable: string name = Console.ReadLine();. A critical point: input is always text — even if the user types 25, what's stored is the string "25", not t
Console.ReadLine() is like holding out a microphone and waiting for the user to answer. What comes back is always text — even if they answered with a number.
- Console.ReadLine()
- Reads one line the user types and returns it as a string.
- input is text
- Everything from ReadLine is a string, even if it looks like a number.
- prompt
- A message (WriteLine) telling the user what to type, before ReadLine.