You can use checked and unchecked blocks to throw or suppress exceptions while converting between data types.
checked{
int max = int.MaxValue;
max = max + 1;
Console.WriteLine(max);
}
Above code will throw an exception, while the below code surpress the exception but prints an overflowed value.
unchecked{
int max = int.MaxValue;
max = max + 1;
Console.WriteLine(max);
}
This will print a funny number, a negative number. But doesnt throw an exception.
