C# number boost

PHPz
PHPzforward
2023-09-17 11:33:201163browse

C# 数字提升

Number promotion, as the name suggests, is to promote a smaller type to a larger type, such as from short to int.

In the example below we see number promotion multiplication in arithmetic operators.

Short types will be 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);
   }
}

The above is the detailed content of C# number boost. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete