Color theme
0 day streak0 XPP1
C#Learn mode
MISSION 1 OF 1

Welcome a visitor without an alias

0 XP earned
C# track: IntermediateMission: IntermediateNullable stringsNull coalescingFallback values
Before you start this intermediate track

Typed collections and functions. Later missions use lambdas, LINQ, and nullable values.

Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.

x
0 / 2 challenges
LEARN THE CONCEPT

Understand it, then try it.

A nullable string may hold either text or null. The question mark in string? makes that possibility explicit. The null-coalescing operator ?? uses its right-hand value only when the left-hand value is null. It therefore supplies a visitor label while preserving any actual alias, including an empty string.

Program.cs
#nullable enableusing System;string? alias = null;string display = alias ?? "Visitor";Console.WriteLine($"Hello, {display}!");

Use C# 10+ in a .NET 6+ console project. Each example is a complete Program.cs using top-level statements; the shown using directives are sufficient. Run missions separately.

Track the values line by line. Predict the result before running this example in your own editor.