Example of catching the OverflowException in C#

static void Main()
{
            int IntVal = 999999;
            checked
            {
                try
                {
                    int data = checked(IntVal * IntVal);
                }
                catch (OverflowException e)
                {
                    Console.WriteLine(e);
                }
            }
}
%d bloggers like this: