Pattern matching โ Advanced
Overview
Section titled โOverviewโAdvanced patterns include relational (<, >), logical (and/or/not), recursive and list patterns.
Introduced In
Section titled โIntroduced InโC# 9โ12 (2020โ2023)
Example
Section titled โExampleโstatic string Describe(int[] a) => a switch{ [0, .. var rest] when rest.Length > 0 => "Starts with 0", [> 10, ..] => "First > 10", _ => "Other"};