Skip to content

Draft Spec for Switch Expression as a Statement Expression in C# 9.0 #2860

@gafter

Description

@gafter

We add the switch expression to the set of syntactic forms permitted in an expression_statement:

expression_statement
    : statement_expression ';'
    ;

statement_expression
    : switch_expression
    // in addition to all the other forms specified elsewhere
    ;

When a switch expression is used as a statement_expression,

  • the expression of each arm of the switch expression is required to be a statement_expression or a throw_expression; and
  • the switch expression is not required to have a type.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions