There is new feature introduced in C# 7.1 called generic pattern matching. One of the examples I found looks like this:
void Attack(IWeapon weapon, IEnemy enemy)
{
switch (weapon)
{
case Sword sword:
// process sword attack
break;
case Bow bow:
// process bow attack
break;
}
}
But from my perspective it's a piece of incorrect design, which violates the second SOLID principle(open-close). I can't even think of the case where this might be needed, from my understanding if you came to situation when you need such switch, then you are doing something very wrong. From other hand, if this feature was added to language, there have to be a strong reason of doing so. So the question is - when would you need this assuming you're not creating poor architecture.