using System;
public class Overflow
{
public static void Main(string[] args)
{
int x = int.MaxValue;
try
{
checked // "Checked" is a block keyword that enables arithmetic overflow checking.
{
int result = x + 1;
Console.WriteLine("No Overflow!");
}
}
catch (OverflowException ex)
{
Console.WriteLine("Overflow Exception caught: " + ex.Message);
}
}
}
/*
run:
Overflow Exception caught: Arithmetic operation resulted in an overflow.
*/