C# User Input

To read input from the console in C#, use the Console.ReadLine() method. In this lesson, we will see an example wherein we have entered the input from the user.

The ReadLine() accepts the input in string format, therefore, we have converted the string to an integer using the Convert.ToInt32() method. Here’s the complete example:


Let’s say the user entered 20, therefore the output will be the following:

C# - Understanding First Program
C# Type Casting
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading