Computer >> Computer tutorials >  >> Programming >> C#

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