Catching an underflow : Byte overflow : Data Type C# Examples


C# Examples » Data Type » Byte overflow »

 

Catching an underflow









    
using  System;

class  MainClass
{
    static  void  Main(string[]  args)
    {
        Console.WriteLine("System.Byte  stats:");
        Console.WriteLine("Max  value  of  byte  is  {0}.",  byte.MaxValue);
        Console.WriteLine("Min  value  of  byte  is  {0}.",  byte.MinValue);

        Console.WriteLine("Catching  an  underflow");
        try
        {
            byte  a  =  9,  b  =  9;
            byte  c  =  (byte)(a  +  b  +  -100);
        }
        catch(OverflowException  e){Console.WriteLine(e);}

    }
}
    
   
  
   



Output

System.Byte stats:
Max value of byte is 255.
Min value of byte is 0.
Catching an underflow


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Byte overflow