Implicit conversion from Int16 to Decimal in C#


The short type represents a 16-bit signed integer i.e. Int16.

To implicitly convert a 16-bit signed integer to a Decimal, firstly set a short value.

short val = -32768;

To convert short to decimal, assign the value.

dec = val;

Let us see another example.

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      short val = -32768;
      decimal dec;
      Console.WriteLine("Implicit conversion from Int16 to Decimal");
      dec = val;
      Console.WriteLine("Decimal : "+dec);
   }
}

Output

Implicit conversion from Int16 to Decimal
Decimal : -32768

Updated on: 23-Jun-2020

148 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements