Created
September 9, 2019 09:36
-
-
Save carlrip/2044f306f79d452456335b9ae388852a to your computer and use it in GitHub Desktop.
C#8 switch expressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string GetLevel(int level) => | |
| level switch | |
| { | |
| 1 => "low", | |
| 2 => "medium", | |
| 3 => "high", | |
| _ => throw new ArgumentException("invalid level"), | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment