is Pattern
noun
say it: “IZ PAT-ern” /ɪz ˈpætərn/
A C# expression with is that tests a value's type or shape, and can give it a new name if it matches.
What is is Pattern in C#?
is Pattern — An is expression that tests a value against a type or another pattern.
class LabelReader
{
int LengthOf(object value)
{
if (value is string text)
{
return text.Length;
}
return 0;
}
}
In a sentence
- “if (item is Ebook e) lets me read e.FileSizeMb safely.”
Level: Journeyman · More C# terms at this level
Updated