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);
   }
}

Advertisements