Skip to content
AgileLogics
3 min read

Reading User Input

Prerequisites: String interpolation

Console.Write("What's your name? ");
string? name = Console.ReadLine();
Console.WriteLine($"Hello, {name}!");

Console.ReadLine() always returns string? (a nullable reference — see Level 2's Nullable Types lesson) since input could theoretically be null if the input stream is closed.