❔ Using compact switch syntax
Is it possible to set
format_code = 1
for case _
using C#8.0 switch syntax?
// int format_code
string format_name = format_code switch
{
0 => "Format8Bits",
1 => "Format16Bits",
2 => "ImaAdpcm",
_ => "UNKNOWN (trying to interpret as Format16Bits)"
};
5 Replies
It's "switch expression", by the by, if you ever need to google it
And no, no straightforward way to do that
You could use a workaround like
I like that approach, will give it a go. Didn't know you could assign multiple values with a switch expression
It uses tuples and tuple deconstruction
Angius#1586
REPL Result: Success
Console Output
Compile: 629.874ms | Execution: 46.902ms | React with ❌ to remove this embed.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.