Before we clarify what pattern matching is, let’s first understand what a pattern is.
What is Pattern Matching?
Patterns test that a value has a certain shape, and can extract information from the value when it has the matching shape.
Ok, so a pattern checks if a value has a certain shape, and if that’s the case, the pattern matches – that’s why it’s called pattern matching.

#csharp 

Improved Pattern Matching C# 9.0 for Beginners
1.65 GEEK