We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6b8fbc8 + 76a8139 commit cb71a29Copy full SHA for cb71a29
documentation/src/basic-constructs.md
@@ -65,7 +65,21 @@ return condition
65
```
66
*ternary operator*
67
68
-## Expression-bodied members
+## Switch Expression
69
+
70
+Prefer switch expressions over switch statements.
71
72
+```csharp
73
+return animalKind switch
74
+{
75
+ AnimalKind.Dog => "dog",
76
+ AnimalKind.Cat => "cat",
77
+ _ => throw new InvalidOperationException($"Unsupported animal kind {animalKind}"),
78
+};
79
+```
80
+*switch expression*
81
82
+## Expression-bodied Members
83
84
Use the expression body syntax when a member returns a single expression.
85
Move the arrow to the next line when the expression gets too long.
0 commit comments