An int, a short, and a float are included in a mathematical expression giving a float result.

image_pdfimage_print
   
 

using System;
class FloatTest 
{
    static void Main() 
    {
        int x = 3;
        float y = 4.5f;
        short z = 5;
        var result = x * y / z;
        Console.WriteLine("The result is {0}", result);
        Type type = result.GetType();
        Console.WriteLine("result is of type {0}", type.ToString());
    }
}

   
     


This entry was posted in Data Types. Bookmark the permalink.