Implicit conversion from 8-bit signed integer (SByte) to Decimal in C#


SByte represents an 8-bit signed integer.

To implicitly convert an 8-bit signed integer to a Decimal, firstly set an sbyte value.

sbyte val = 51;

To convert sbyte to decimal, assign the value.

decimal d;
d = val;

Let us see another example.

Example

using System;
public class Demo {
   public static void Main() {
      sbyte val = 39;
      decimal d;
      Console.WriteLine("Implicit conversion from 8-bit signed integer (sbyte) to Decimal");
      d = val;
      Console.WriteLine("Decimal = "+dec);
   }
}

Updated on: 23-Jun-2020

151 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements