lenelex.com
Home
Quizzes
Games
Register
Log in
Question 1 of 8
What will be the output of the following code?
try { byte n = byte.MaxValue; checked { Console.Write(++n); } } } catch (Exception ex) { Console.Write(ex.GetType().Name); }
A. 0
B. OverflowException
C. 256
D. 255
Enabling overflow-checking
By default, non-constant integral-type arithmetic expressions are not checked for overflow at run time. Overflow checking can be enabled by compiler options, environment configuration, or use of the checked keyword.
Links:
The Checked Keyword
The Increment Operator (++)