Null and ?
A variable of a reference type, such as string, holds a reference: the address of an object on the heap. null is the reference to no object at all. Line 1 sets name to null.
New projects switch on nullable reference types. Then plain string promises never null, and string? says maybe null. The ? is only a note for the compiler, Roslyn: at run time both are the same string type.
A value type such as int holds its value directly, so it can never be null. int? is short for Nullable<int>: an int plus a HasValue flag. Line 2 makes age with HasValue false, which reads as null.
The null operators
name.Length would fail here, because name is null. name?.Length checks first: if name is null, the answer is null instead. Then ?? 0 swaps that null for 0, so n is a plain int: 0.
age ??= 30 means: if age is null, give it 30; otherwise leave it alone. age was null, so now age is 30 and HasValue is true. Running the line again would change nothing.
Null safety
Line 5 puts a reference to the string "Ada" (an object on the heap) in name. name is not null any more: it now refers to a real object.
Roslyn follows every variable through the code. After line 5 it knows name is not null, so name.Length on line 6 gets no warning. Line 6 runs: n becomes 3, the length of "Ada".
n + age adds an int and an int?. C# lifts + to work on nullables: if either side is null, the answer is null. Here both have values, so it is 33, and Console.WriteLine prints 33.
What if line 5 were gone? Roslyn would warn CS8602 on line 6: name may be null here. Run it anyway and name.Length throws a NullReferenceException, which stops the program. Treat each warning as a bug.
What happens
// step 1/9 · null line 1 string? name = null; string a reference type: the variable holds an address null the reference to no object name null
The program is real C#. With nullable reference types on (the default for new .NET 6+ projects), it builds with no warnings and prints 33. The variables row shows what the three local variables hold. Where the runtime keeps locals (stack slots or CPU registers) is its own choice.