LANGUAGE

checked overflow context

Selected integral arithmetic and conversions throw on overflow in a checked context. Does not catch exceptions or protect code textually outside that context.

Formal Syntax & Structure

csharp syntaxcsharp
checked(expression)

Working Example

Example Snippetcsharp
long wide = 250; int count = checked((int)wide);
C# & .NET Reference