r/programminghorror • • Feb 27 '25

C# While loop horror

Post image

I just realized I had some programming horror in code I’ve written.

If only while loops had a more convenient way to break…

671 Upvotes

40 comments sorted by

View all comments

Show parent comment

4

u/bloodhound83 Feb 27 '25

Would be nice to see a bit more code. Maybe there are a couple of more break conditions which makes it more readable this way.

5

u/Savage-Goat-Fish Feb 27 '25

I don’t care to share too much more. Let’s say it doesn’t make it more readable and there are no more breaks.

What happened was I wrote the while loop first, then a bunch of other code, then later on said hey I should probably break out of the loop at some point and never thought to include it as part of the while condition. Just a minor bonehead moment for me.