Implicit conversion from 32-bit unsigned integer (UInt) to Decimal in C#

CsharpProgrammingServer Side Programming

Implicit conversion of a 32-bit unsigned integer (UInt) to a Decimal requires you to first declare a UInt.

uint val = 342741539;

Now to convert it to decimal, just assign the value.

decimal dec;
// implicit
dec = val;

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      uint val = 342741539;
      decimal dec;
      // implicit
      dec = val;
      Console.WriteLine("Decimal = "+dec);
   }
}

Output

Decimal = 342741539
raja
Published on 14-Sep-2018 13:00:33
Advertisements