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
Updated on: 2020-06-23T07:17:31+05:30

285 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements