Console.ReadLine() Method in C#


The Console.ReadLine() method in C# is used to read the next line of characters from the standard input stream.

Syntax

The syntax is as follows −

public static string ReadLine ();

Example

Let us now see an example to implement the Console.ReadLine() method in C# −

using System;
public class Demo{
   public static void Main(){
      string str;
      Console.WriteLine("Enter any subject...");
      str = Console.ReadLine();
      Console.WriteLine("Entered subject = "+str);
   }
}

Output

This will produce the following output −

Enter any subject...
Entered subject = Maths

Updated on: 14-Nov-2019

758 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements