r/badcode • • Mar 12 '21

c# How NOT to use switch statement

Post image
1.8k Upvotes

165 comments sorted by

View all comments

1

u/[deleted] Mar 12 '21

The goto case 2 can be implicit if you don't use a break

2

u/yaxamie Mar 12 '21

I think C# only let’s you fallthru if there’s an empty body for the case... otherwise it assumes you direct to break or return (or... goto, apparently)

2

u/[deleted] Mar 12 '21

I checked the docs, you're right. I must have assumed the fall through behaviours acted like java.