type pattern
A pattern that tests a value's type and, if it matches, gives the converted value a name, as in if (boxed is int n).
In more detail
It replaces a type check followed by a cast. is null and is not null are the everyday null checks.
Related terms
- pattern matching — Testing a value against a shape, such as a type, a range or the values of its properties, and optionally extracting parts of it in the same step.
- cast — An explicit conversion written (Type)value that tells the compiler to treat a value as another type, and throws at run time if it is not.
Taught in
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices