Conversions of numeric types : Data Type Cast : Data Type C# Examples


C# Examples » Data Type » Data Type Cast »

 

Conversions of numeric types









    
using  System;

class  MainClass
{
        public  static  void  Main()
        {
                uint  value1  =  999;
                byte  value2;
                
                value2  =  unchecked((byte)  value1);        //  never  checked
                value2  =  (byte)  value1;                        //  checked  if  /checked
                value2  =  checked((byte)  value1);                //  always  checked
        }
}
    
   
  
   



Output

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


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Data Type Cast