C# Numeric Promotion


Numeric promotion as the name suggests is the promotion of smaller types to larger types like short to int.

In the below example, we have seen numeric promotion in Arithmetic Operator multiply.

The short types are automatically promoted to larger types −

Example

using System;

class Program {
   static void Main() {
      short val1 = 99;
      ushort val2 = 11;

      int res = val1 * val2;
      Console.WriteLine(res);
   }
}

Updated on: 21-Jun-2020

234 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements