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.

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
raja
Published on 12-Sep-2018 09:43:34
Advertisements