Practice ยท 3 of 3
Make Null a Contract
CHALLENGE
Difficulty: intermediate+25 XP
Rebuild a fragile API around honest nullability:
``csharp
/* Parses a positive integer; null when input is null, blank, or not a
positive integer. */
static int? ParsePositive(string? input);
/* First key in the dictionary whose value is > threshold; null when none.
Dictionary iteration order is insertion order โ first match wins. */
static string? FirstAbove(Dictionary<string, int> scores, int threshold);
/* Defaults: name null/blank -> "guest"; else trimmed name. */
static string DisplayName(string? name);
``
Press Submit to check your solution.
Back to lesson: Practice: Semantics Gym