Checked Operator in C#

The checked keyword is used to control the overflow-checking context for integral-type arithmetic operations and conversions. It can be used as an operator or a statement according to the following forms.

This blog shows on how to use a Checked Operator in C#

checked
{
   // Start of checked block
   Byte b = 100;
   b = (Byte) (b + 200); // This expression is checked for overflow.
}
// End of checked block
Ebook Download
View all
Learn
View all