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

C Sharp

1501 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
top 9 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 6 months ago* (last edited 6 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

[–] [email protected] 3 points 6 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 6 months ago (1 children)

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

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

That doesn't sound very effective though.

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

It works for older platforms that only run CF 3.5

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

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

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

Why post a stack exchange from 2008?

[–] [email protected] 4 points 6 months ago* (last edited 6 months ago) (1 children)

Because it is about a not-very-well-known feature of the language. Why would it matter that it's old? I don't think I have ever seen this in use in production code.

[–] [email protected] 1 points 6 months ago

An explanation like that at the start would have been helpful. I was reading the page and just didn't understand. Was thinking at first it was to raise awareness of an unanswered question. Couldn't figure it out so I asked.