Cast an int into a byte, data lost : Data Type Cast : Data Type C# Examples


C# Examples » Data Type » Data Type Cast »

 

Cast an int into a byte, data lost









    
using  System;  
  
class  Example  {        
    public  static  void  Main()  {        
        byte  b;  
        int  i;  
        
        i  =  257;  
        b  =  (byte)  i;    
        Console.WriteLine("b  after  assigning  257:  "  +  b  +  
                                            "  --  data  lost.");  
  
    }
}
    
   
  
   



Output

b after assigning 257: 1 -- data lost.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Data Type Cast