April 2018
Intermediate to advanced
292 pages
6h 44m
English
The application can read data from the standard input stream using a few methods from the Console static class from the System namespace, such as ReadLine and ReadKey. Both are presented in the examples in this section.
Let's take a look at the following line of code:
string fullName = Console.ReadLine();
Here, you use the ReadLine method. It waits until the user presses the Enter key. Then, the entered text is stored as a value of the fullName string variable.
In a similar way, you can read data of other types, such as int, as shown as follows:
string numberString = Console.ReadLine(); int.TryParse(numberString, out int number);
In this case, the same ReadLine method is called and the entered text is stored as a value ...