Blame C/C++ for the switch complaint. C#'s design was to avoid a lot of those nasty pitfalls by making you be explicit about your intent. You don't have to use a break, but you do have to explicitly exit out of the switch, so a return, or throw, or (gasp) goto works also. This means forgetting a break is a compiler error, not the silent execution of subsequent cases, which is probably a trick employed purposefully in C++ like 5% of the time and a nasty bug for every other instance.
Re:Is C# Underhyped?
by cableshaft on Thursday December 07, 2023 @11:27PM
(#38565447)
> why do C# switch statements require break? Fall-through isn't supported
Yes it is. I've got it in my game right now. It totally supports fall-through.
... by using a goto case, which you can put anywhere in a case. The break remains non-functional.
Re:Is C# Underhyped?
by neonsunset on Friday December 08, 2023 @07:55AM
(#38568444)
Switch in C# is pretty much Rust's 'match' (aside from Rust having unit type and being expression oriented which gives it an advantage). It support list pattern matching, object type and member pattern matching, inline slice patterns, etc. You don't need to use switch statements for that either, switch expressions is the recommended syntax today and IDE is likely to even suggest to auto-fix some of the idioms it can recognize.
Ignoring the big issues, it's paper cut after paper cut.
It's infuriating after you've used a language with thoughtful ergonomics.