Reading Integers from the Console

In order to read an integer (not a float) number from the console, we have to declare a variable, declare the number type and use the standard command for reading a text line from the system console Console.ReadLine() and after that convert the text line into an integer number using int.Parse(text):

var num = int.Parse(Console.ReadLine());

The above line of C# code reads an integer from the first line on the console.

Video: Reading Data from the Console

Watch a video lesson about reading from the system console here: https://youtu.be/WPlQ5HYBGJQ.

Video: Reading Integers from the Console

Watch a video lesson about reading integer numbers from the system console here: https://youtu.be/3TC2F-ffw34.

results matching ""

    No results matching ""