Created
August 2, 2018 11:56
-
-
Save DavidArno/ff9f08392988dab2ca1e5ba1d87d684d to your computer and use it in GitHub Desktop.
Switch expression example
This file contains 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 class C | |
{ | |
RedisValue ToRedisValue(object obj) | |
{ | |
return obj switch | |
{ | |
null => Null, | |
RedisValue v => v, | |
string v => (RedisValue)v, | |
int v => v, | |
double v => v, | |
byte[] v => (RedisValue)v, | |
// ... | |
_ => Null | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment