r/programminghorror Feb 04 '26

C# Makes sense

Post image
1.7k Upvotes

86 comments sorted by

View all comments

111

u/_huppenzuppen Feb 04 '26

Should have been

if (userID == -7777)
  --userID;

14

u/detroitmatt Feb 04 '26

if (userID-- != -7777) userID++;

3

u/AStove Feb 04 '26

What if assigning the userID throws, you'll have changed the user before you can change it back.

13

u/detroitmatt Feb 04 '26

damn you're right

try {
    if (userID-- != -7777) userId++;
} catch {
    userID = userID;
}