OverflowException
using System;
class MainClass
{
public static void Main(){
int value = 987000000;
checked {
try {
// Square the original value.
int square = value * value;
Console.WriteLine("{0} ^ 3 = {1}", value, square);
}
catch (OverflowException) {
double square = Math.Pow(value, 2);
Console.WriteLine("Exception: {0} > {1:E}.", square, Int32.MaxValue);
}
}
}
}
Related examples in the same category