Pattern Matching
Testing a value's type, shape, or contents while optionally extracting parts of it.
What is Pattern Matching in C#?
Pattern Matching — Testing a value's type, shape, or contents while optionally extracting parts of it.
class LabelReader
{
int LengthOf(object value)
{
if (value is string text)
{
return text.Length;
}
return 0;
}
}
Level: Journeyman · More C# terms at this level
Updated