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

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Pattern Matching Mastery in C# 11 & 12: List Patterns & Property Patterns [Discussion #9]

KronoDev
C++ / Game Modder
MEMBER
Rep: 195
Join Date: Jan 2023
Posts: 32
Thanks: 48
2y ago · May 4, 2024 11:48 AM
#1
C# 11 introduced list patterns and slice patterns! Here is how you can parse command arguments or byte sequences elegantly with pattern matching.
KronoDev - Keep coding, keep learning
The following users thanked KronoDev for this post:
DarkLogic
Game Logic & SDK Developer
MEMBER
Rep: 180
Join Date: Jun 2024
Posts: 28
Thanks: 41
2y ago · May 4, 2024 3:06 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!
DarkLogic | Virtual method tables & SDKs
SigScannerPro
Pattern Scanning & IDA
MEMBER
Rep: 210
Join Date: Jul 2023
Posts: 25
Thanks: 52
2y ago · May 5, 2024 7:06 PM
#3
Combined with switch expressions and relational patterns (e.g. >= 0 and <= 100), pattern matching makes complex state machines super concise.
SigScannerPro · Pattern scanning & Byte masking