Skip to main content

Checkpoint: Type Semantics Under Pressure

Challenge on lesson: Checkpoint โ€” Advanced Type System

CHALLENGE
Difficulty: intermediate+25 XP

Three functions in one graded unit โ€” value/reference, nullability, and patterns together: ``csharp /* 1. Returns true iff the SAME object (reference equality), false for equal-but-distinct boxes; null-safe both sides. */ static bool IsSameInstance(object? a, object? b); /* 2. Classifies with a switch expression (exact strings): null -> "empty"; empty/whitespace -> "blank"; parses as int -> "int:<n>"; any other -> "text:<input>" */ static string Classify(string? input); /* 3. Deconstructs: returns (min, max) of the numbers; empty or null sequence -> (0, 0). */ static (int Min, int Max) Range(IEnumerable<int>? numbers); ``

Back to lesson: Checkpoint โ€” Advanced Type System