O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.4. checked and unchecked operators and statements

The checked keyword is useful for detecting overflows [5] in integral-type arithmetic operations and conversions.

[5] An overflow results when you are trying to store an integer value which is beyond the range of the integral variable. For example, the short type's range is only -32 768 to +32 767. An attempt to store a value greater than 32 767 into a short type causes an overflow. An attempt to store a value smaller than -32 768 into a short type causes an underflow. No distinction is made between underflow and overflow in this book. When I use the term 'overflow', I am referring to both overflow and underflow scenarios.

10.4.1. The checked keyword

The checked keyword can be used in one of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required