C# program for Checked Statement

This is the simple example of a c# program, in which we can see how to use checked statement
and also how it works.

The checked statement force c# to raise the exception error
whenever stack underflow or overflow occurred
due to the integral type arithmetic or conversion issue.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Checked_statement
    class PostSlush
        public static void Main(string[] args)
            int no;
        // assign maximum value
        no = int.MaxValue;
              // forces stack overflow exception
              no = no + 1;
        catch (Exception e)


Output :
Share Your Comments

Previous Huawei Ascend G740 arrives in France
Next C# program for Unchecked Statement

About author

You might also like