Before C# 7.0, the following code was valid:
if(x is X)
{
//...
}
Now, the following is also valid:
if(x is X _)
{
//...
}
Accoding to TryRoslyn, those code sections generates the same IL. My question is: what's the purpose of the discard operator in pattern matching, if it is not necessary neither useful? Am I missing something here?
This question is not the same as that one, since I'm asking the purpose of the discard operator (wildcard) specifically for the pattern matching (is
operator).