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

CsharpProgrammingServer Side Programming

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
raja
Published on 11-Sep-2018 13:18:29
Advertisements