Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pattern matching with C# 7
public void PatternMatchingWithIsOperator(object o)
{
if (o is 42)
{
}
if (o is Person p)
{
}
if (o is var v1)
{
}
}
public void PatternMatchingWithSwitchStatement(object o)
{
swtich (o)
{
case 42:
break;
case Person p when p.FirstName == "Katharina":
break;
case Person p:
break;
case var v:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment