csharpstandard
csharpstandard copied to clipboard
8.0 Tuple parentheses optional in switch expression and statement
When a tuple is used as the expression for a switch statement (or expression), the tuple doesn't need parentheses. For example:
void M(bool a, bool b)
{
switch (a,b) // This is the tuple (a,b), but the parentheses are for the switch expression, not the tuple.
{
case (true, true):
break;
case (true, false):
break;
case (false, true):
break;
case (false, false):
break;
}
}
This is specified in https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/patterns.md
This is specified in https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/patterns.md
But this is not specified in 13.8.3 The switch statement, so this conflicts with the syntax in the standard, should it be updated together?
The switch statement is modified to handle this in PR https://github.com/dotnet/csharpstandard/pull/873.