Implicit conversion from 16-bit unsigned integer (ushort) to Decimal in C#


UShort represents a 16-bit unsigned integer.

To implicitly convert of a 16-bit unsigned integer to a decimal, firstly set a ushort value.

ushort val = 193;

To convert ushort to decimal, assign the value.

decimal dec;
dec = val;

Let us see an example.

Example

using System;
public class Demo {
   public static void Main() {
      ushort val = 2567;
      decimal dec;
      Console.WriteLine("Implicit conversion from 16-bit unsigned integer to Decimal");
      dec = val;
      Console.WriteLine("Decimal = "+dec);
   }
}

Updated on: 23-Jun-2020

269 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements