Switch Statements - Fallthrough (#18405)

This commit is contained in:
FlyvendeThom
2018-10-14 18:22:35 +02:00
committed by Quincy Larson
parent 15329a240e
commit 5cbe21754a

View File

@ -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