Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.0 Tuple parentheses optional in switch expression and statement #576

Open
BillWagner opened this issue May 11, 2022 · 3 comments
Open
Milestone

Comments

@BillWagner
Copy link
Member

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;
            
    }
}
@BillWagner BillWagner changed the title 7,0 7.0 Tuple parentheses optional in switch expression and statement May 11, 2022
@gafter gafter changed the title 7.0 Tuple parentheses optional in switch expression and statement 8.0 Tuple parentheses optional in switch expression and statement May 13, 2022
@gafter
Copy link
Member

gafter commented May 13, 2022

@gafter gafter added this to the C# 8.0 milestone May 13, 2022
@geniuszxy
Copy link

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?

@RexJaeschke
Copy link
Contributor

The switch statement is modified to handle this in PR #873.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants