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


C# Examples » Data Type » Data Type Cast »

 

Cast an int into a byte, no data lost









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

}
    
   
  
   



Output

b after assigning 255: 255 -- no data lost.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Data Type Cast