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

C Sharp

1526 readers
1 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@programming.dev 3 points 9 months ago* (last edited 9 months ago) (5 children)

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

[–] notnotmike@programming.dev 3 points 9 months ago (4 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

[–] CCMan1701A@startrek.website 1 points 8 months ago (1 children)

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

[–] mihies@kbin.social 1 points 8 months ago (1 children)

That doesn't sound very effective though.

[–] CCMan1701A@startrek.website 1 points 8 months ago (1 children)

It works for older platforms that only run CF 3.5

[–] mihies@kbin.social 3 points 8 months ago

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

load more comments (2 replies)
load more comments (2 replies)