-
Couldn't load subscription status.
- Fork 1
Overflow Checking
Mario Gutierrez edited this page Jan 7, 2017
·
1 revision
You can use the checked keyword to carry out a checked cast, which checks for numeric overflow when narrowing a scope.
Block form:
checked
{
byte a = (byte)someIntegerA;
byte b = (byte)someIntegerB;
}Inline form:
checked(byte a = (byte)someIntegerA);If you can enabled overflow checking project-wide, you can use the unchecked keyword in a similar fashion to ignore checking.
The project-wide setting is usually in "Build Settings > Check for arithmetic overflow/underflow".
- Abstract Classes
- Access Modifiers
- Anonymous Methods
- Anonymous Types
- Arrays
- Attributes
- Console I/O
- Constructors
- Const Fields
- Delegates
- Enums
- Exceptions
- Extension Methods
- File IO
- Generics
- Interfaces
- Iterators
- LINQ
- Main
- Null Operators
- Parameters
- Polymorphism
- Virtual Functions
- Reflection
- Serialization
- Strings
- Value Types
- "Base" Keyword
- "Is" and "As"
- "Sealed" Keyword
- nameof expression