# Pattern Matching

*noun*

say it: **“PAT-ern MACH-ing”** **/ˈpætərn ˈmætʃɪŋ/**

Checking a value's type, shape or contents in C#, such as with is or in a switch.

## What is **Pattern Matching** in C#?

**Pattern Matching** — Testing a value's type, shape, or contents while optionally extracting parts of it.

```csharp
class LabelReader
{
    int LengthOf(object value)
    {
        if (value is string text)
        {
            return text.Length;
        }

        return 0;
    }
}
```

## In a sentence

- “With **pattern matching**, score is >= 90 and &lt;= 100 reads almost like English.”

Level: Journeyman · [More C# terms at this level](https://www.ask-codey.com/glossary?category=c-sharp&level=3)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/pattern-matching
