Input is a sequence of lines with an end
Console.ReadLine requests the next line from the program's standard input. It returns the line's contents without the terminating newline, or null when no more input is available. A blank line and the end of input are different states: a blank line is an empty string that was actually supplied, while null means there is no next line. Preserving that distinction matters when the program validates required fields or reads several records in a loop.
SharpRune prepares standard input before a run. Put the intended lines in the Input panel, then start execution. The sample does not present a live interactive prompt that waits for a new keyboard response after it has already finished. A later edit to the Input panel belongs to a later run. This model makes exercises reproducible: the source and prepared input together determine which values each ReadLine call receives and when the sequence is exhausted.
Trace the prepared Ada line
With one prepared line containing Ada, the first ReadLine returns the string Ada. The variable name receives that value. WriteLine then prints Ada followed by its own output newline, so the expected result is one visible line, Ada. The input's terminating newline is not retained inside the name value. There is no need to trim a line terminator from the returned string, and the program does not automatically repeat for additional names.
If the Input panel supplies no lines, ReadLine returns null. Passing that null string to WriteLine prints a line terminator without visible text, so the run can succeed while the output looks blank. That is different from a compiler error and different from printing the literal four-letter word null. If the panel contains Ada and Sam on separate lines, this unchanged program still reads only Ada because there is only one ReadLine call. The remaining prepared line is unused.
var name = Console.ReadLine();
Console.WriteLine(name);Do not confuse missing input with a failed runtime
A successful run does not imply that a required name was supplied. The sample deliberately has no validation and accepts the null result as something WriteLine can display harmlessly. Calling name.Length without accounting for null would introduce a possible runtime failure. Likewise, using an empty-string check alone does not express whether missing input and a supplied blank line should be handled identically. Choose the application's rule first, then implement both relevant cases explicitly.
Consume another line, then validate the first one
First add a second ReadLine and a second WriteLine. Prepare Ada and Sam as two lines and predict the output order: Ada first, then Sam. Run again with only Ada prepared and explain why the second printed line is blank. Hint: each read consumes one line, and the exhausted stream does not reuse its last value. This exercise tests the input sequence, not how quickly you type after pressing Run.
Next restore the original single read and print a message such as missing name when the result is null or empty. Test three cases separately: no prepared line, an explicitly blank line, and Ada. Then decide whether whitespace-only text should count as missing and update the rule deliberately. Hint: string.IsNullOrWhiteSpace describes a broader policy than checking Length equal to zero. Keep the original and modified expectations separate so a new validation message is not mistaken for the original sample's output.
Specify source and input together
Before sharing a reproduction, record the exact prepared input as well as the code. State how many ReadLine calls run and what each receives. Explain the difference between an empty string and null, and why both can lead to visually blank console output. A program that requires input should validate that requirement itself; the runtime cannot infer a useful default name merely because an exercise normally uses Ada.
- Prepare Ada before Run to reproduce the catalog result.
- ReadLine removes the input line terminator.
- No next line returns null, not the text
null. - Changing prepared input affects the next run.
A working example
var name = Console.ReadLine();
Console.WriteLine(name);Expected output
Ada
Empty input is still a successful run.