Switch Statements - Fallthrough (#18405)
This commit is contained in:
committed by
Quincy Larson
parent
15329a240e
commit
5cbe21754a
@ -45,5 +45,20 @@ If myColor is Colors.Orange:
|
||||
|
||||
```
|
||||
|
||||
## Fallthrough
|
||||
|
||||
It is also possible to use multiple statements produce the same outcome, by letting the cases 'fallthrough', like so:
|
||||
|
||||
```
|
||||
switch(myColor) {
|
||||
case Colors.Red:
|
||||
case Colors.Blue:
|
||||
//Code
|
||||
break;
|
||||
...
|
||||
}
|
||||
```
|
||||
This will execute the same lines of code if myColor is either Red or Blue.
|
||||
|
||||
### Sources:
|
||||
- 1 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/switch
|
||||
|
Reference in New Issue
Block a user