Implicit Conversion from uint64 to Decimal in C#



The ulong type represents a 64-bit unsigned integer i.e. UInt64.

To implicitly convert a 64-bit unsigned integer to a Decimal, firstly set UInt64 value.

ulong val = ulong.MaxValue;

To convert ulong to decimal, assign the value.

decimal dec;
dec = val;

Let us see the above example.

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      ulong val = ulong.MaxValue;
      decimal dec;
      Console.WriteLine("Implicit conversion from Ulong to Decimal");
      dec = val;
      Console.WriteLine("Decimal : "+dec);
   }
}

Output

Implicit conversion from Ulong to Decimal
Decimal : 18446744073709551615
Updated on: 2020-06-23T07:48:53+05:30

387 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements