The sceptics guide to pattern matching
summary
C# pattern matching evolves from C#7 through C#10 into concrete features: switch expression, property pattern, positional pattern, plus type, constant, discard, var, relational and logical patterns. The compiler rewrites patterns into nested type/null checks and jumps (so decompiled code looks like ifs/gotos), relational patterns only compare to constants, null-checks are automatic, and the compiler enforces exhaustiveness. Practical wins: concise state tables (toll/peak-time example), cleaner tree algorithms and a compact red‑black tree rebalance, all reducing nested ifs and extracting deep data.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 2:00Pattern matching in other languages
- 6:44Patterns in C
- 6:57Where to use patterns
- 9:57Type patterns
- 14:52Property patterns
- 17:47recursive patterns
- 24:20positional patterns
- 26:24Deconstruction
- 32:06How do patterns work
- 45:24Switch
- 47:08Examples
- 49:26Peak Time Premium
- 51:56What patterns are good for
related talks
42mC#'s functional journey
01h 06mFunctional Design Patterns
30mConcrete Syntax Metapatterns
57mDesign Patterns - The Most Common Misconceptions (2 of N)
34mNot Your Uncle’s Clean Code (TypeScript Edition)
31mCode Patterns for Pattern Making
34mDiscovering Parallel Pattern Candidates
36mBuilding Strong Code Through Patterns
