Code inspection: Possible overflow in 'checked' context
This inspection reports arithmetic on int values that can overflow in a checked context. In a checked context, such overflow throws an exception at runtime.
Example
checked
{
int value = int.MaxValue + 1;
}
This code throws because the result is outside the valid int range.
How to fix it
There is no dedicated quick-fix for this inspection. Typical fixes are to use a wider type, validate the input before the operation, or change the arithmetic so overflow cannot happen.
checked
{
long value = (long)int.MaxValue + 1;
}
01 April 2026