An int, a short, a float, and a double are added together giving a double result.

image_pdfimage_print
   
 
using System;
// Mixing types in expressions
class MixedTypes
{
    static void Main()
    {
        int x = 3;
        float y = 4.5f;
        short z = 5;
        double w = 1.7E+3;
        // Result of the 2nd argument is a double:
        Console.WriteLine("The sum is {0}", x + y + z + w);
    }
}

   
     


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