Implicit conversion from UInt64 to Decimal in C#

CsharpProgrammingServer Side Programming

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.


 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);


Implicit conversion from Ulong to Decimal
Decimal : 18446744073709551615
Updated on 23-Jun-2020 07:48:53