short shorty = 32767; // largest positive short
int integer = shorty + 1;
try
{
checked // force compiler to object
{
shorty = (short) integer; // try to cram it into a short
}
}
catch (OverflowException e)
{
//"Arithmetic operation resulted in an overflow."
Console.WriteLine (e.Message);
}