Syntax

C# Read Input Syntax

In C#, read input: reads a line from the console — string? line = Console.ReadLine();

Quick Answer

Syntax
string? line = Console.ReadLine();
C#Syntax

Read Input

Code example
string? line = Console.ReadLine();

Reads a line from the console.

Learn More

How to read input in C#

  1. Open your C# file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C# Read Input Syntax

Use string? line = Console.ReadLine();.

Related Syntax References

Frequently asked questions

What is the C# syntax for read input?

Use this pattern: string? line = Console.ReadLine();

Can I copy this C# code example?

Yes. Use Copy code and adapt the example to your program.

Is this C# syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify