What happens when C# evaluates checked(x + 1) where x is an int variable holding int.MaxValue?
Correct answer B. An OverflowException is thrown
Explanation
Inside a checked expression or block, integral arithmetic that overflows its type throws System.OverflowException instead of wrapping. Since int.MaxValue + 1 does not fit in an int, the runtime raises the exception. C# never silently widens to long. Use checked for financial or counting code where a wrapped value would be a silent bug, and unchecked where wrapping is intended, such as hashing.
Answer checked How we write and check questions
Discussion