Cast an int into a double : Data Type Cast : Data Type C# Examples


C# Examples » Data Type » Data Type Cast »

 

Cast an int into a double









    
using  System;  
  
class  Example  {        
    public  static  void  Main()  {        
        double  x,  y;  
        int  i;  

        x  =  10.0;  
        y  =  3.0;  
  
        i  =  (int)  (x  /  y);  //  cast  double  to  int,  fractional  component  lost  
        Console.WriteLine("Integer  outcome  of  x  /  y:  "  +  i);  
        Console.WriteLine();  
          
    }        
}
    
   
  
   



Output

Integer outcome of x / y: 3


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Data Type Cast