Raises the OverflowException exception : Data Type Cast : Data Type C# Examples


C# Examples » Data Type » Data Type Cast »

 

Raises the OverflowException exception









    
using  System;

class  MainClass
{
      static  void  Main(string[]  args)
      {
            ushort  sh  =  2000;
            byte  sb;

            sb  =  checked((byte)sh);                            
            Console.WriteLine("sb:  {0}",  sb);
      }
}
    
   
  
   



Output

Unhandled Exception: System.OverflowException: Arithmetic operation resulted in an overflow.
   at MainClass.Main(String[] args)


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Data Type Cast