byte overflow with unchecked : Byte overflow : Data Type C# Examples


C# Examples » Data Type » Byte overflow »

 

byte overflow with unchecked









    
using  System;

class  MainClass
{
    static  void  Main(string[]  args)
    {
        Console.WriteLine("Working  with  unchecked  code");
        try
        {
            unchecked
            {
                byte  b5  =  100,  b6  =  200;
                byte  b4  =  (byte)(b5  +  b6);
                Console.WriteLine("b4  =  {0}",  b4);              
            }
        }
        catch(OverflowException  e)
        {  
            Console.WriteLine(e.Message);
        }        
    }
}
    
   
  
   



Output

Working with unchecked code
b4 = 44


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Byte overflow