Skip to content
CShift0.32

ConsoleInput

Reading the standard input: the compiler calls ReadLine for Console.ReadLine().

Name Description
ReadLine The next line of the standard input, without its line break (\n or \r\n); null at the end of the input.
Optional<string> ReadLine()

The next line of the standard input, without its line break (\n or \r\n); null at the end of the input. What the program wrote to the console before is shown first (Console.Write("Name: ") without a line break as a prompt). Bytes that are not valid UTF-8 become ?.

Console.Write("Name: ");
if (Console.ReadLine() is string name)
Console.WriteLine("Hello, " + name);

Since 0.28