checked integer adding - CSharp Language Basics

CSharp examples for Language Basics:int

Description

checked integer adding

Demo Code


using System;//from   w  w w. ja  v  a 2 s  . co  m

class sizes
{
   public static void Main()
   {
       int val1 = 2147483647;
       int val2;

       checked
       {
          val2 = val1 +1;
       }

       Console.WriteLine( "val1 is {0}", val1);
       Console.WriteLine( "val2 is {0}", val2);
   }
}

Result


Related Tutorials