this post was submitted on 16 Feb 2024
6 points (68.8% liked)

C Sharp

1532 readers
2 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] starman 3 points 9 months ago* (last edited 9 months ago) (1 children)

IMO, it would be more readable to just use ifs most of the times. But switch-case fallthrough is indeed, interesting behaviour

[–] notnotmike 4 points 9 months ago (1 children)

Agreed, multiple if statements are much more readable, in my opinion. I generally think switch statements are always just a little too ugly unless their dead simple.

Switch expressions, on the other hand, are gorgeous code (as long as you don't use expression-bodied cases). I am always looking for chances to use switch expressions. So concise

[–] [email protected] 1 points 8 months ago (1 children)

When the if/else is large I'm in the dictionary of functions boat.

[–] [email protected] 1 points 8 months ago (1 children)

That doesn't sound very effective though.

[–] [email protected] 1 points 8 months ago (1 children)

It works for older platforms that only run CF 3.5

[–] [email protected] 3 points 8 months ago

Is CF still a thing? But anyway, if it works, it works :)