Is there a way to do this
int i = object.GetString() switch
{
"this" => 1,
"that" => 2,
"the other" => 3,
_ => someMethod([switch value])
}
to use the value being switched on inside the switch expression? Or do I have to do this
var myString = object.GetString()
int i = myString switch
{
"this" => 1,
"that" => 2,
"the other" => 3,
_ => someMethod(myString)
}
I know it's not that big of a deal to declare myString; I'm just wondering if the syntax exists.