News for hackers. Stuff that matters.
Re:Parse, Don't Validate (2019) by Archelaos on Tuesday February 10, 2026 @01:51PM (#46964917)
In C# I use the 'checked' keyword in this or similar cases, when it might be relevant: c = checked(a - b);

Note that this does not violate the "Parse, Don't Validate" rule. This rule does not prevent you from doing stupid things with a "parsed" type.

In other cases, I use its cousin unchecked on int values, when an overflow is okay, such as in calculating an int hash code.

There are no comments on this comment yet.