Implicit conversion from 64-bit signed integer (long) to Decimal in C#


The long type represents a 64-bit signed integer.

To implicitly convert a 64-bit signed integer to a Decimal, firstly set a long value.

long val = 989678876876876;

To convert long to decimal, assign the value.

dec = val;

Let us see another example −

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      long val = 76755565656565;
      decimal dec;
      Console.WriteLine("Implicit conversion from 64-bit signed integer (long) to Decimal");
      dec = val;
      Console.WriteLine("Decimal : "+dec);
   }
}

Output

Implicit conversion from 64-bit signed integer (long) to Decimal
Decimal : 76755565656565

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 23-Jun-2020

166 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements