Home / Forums / Pattern Matching Mastery in C# 11 & 12: List Patterns & Property Patterns

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Pattern Matching Mastery in C# 11 & 12: List Patterns & Property Patterns

RenderMaster
ImGui UI Designer
VIP
Rep: 310
Join Date: Sep 2023
Posts: 32
Thanks: 82
2y ago · May 13, 2024 12:36 PM
#1
C# 11 introduced list patterns and slice patterns! Here is how you can parse command arguments or byte sequences elegantly with pattern matching.
RenderMaster | Clean UI Design & Dear ImGui widgets
The following users thanked RenderMaster for this post:
MatrixRecon
3D Math & Vectors
MEMBER
Rep: 225
Join Date: Jan 2025
Posts: 33
Thanks: 55
2y ago · May 13, 2024 1:55 PM
#2
List patterns like if (args is ["move", var x, var y]) make parsing input commands read like plain English instead of index checking!
MatrixRecon · 3D Mathematics & View Matrix Calculations
KernelDiver
Kernel & Systems Researcher
VIP
Rep: 275
Join Date: Jan 2024
Posts: 24
Thanks: 70
2y ago · May 14, 2024 4:55 PM
#3
Combined with switch expressions and relational patterns (e.g. >= 0 and <= 100), pattern matching makes complex state machines super concise.
KernelDiver · Windows Internals & Page Tables