Implicit conversion from Int32 to Decimal in C#


The int type represents a 32-bit signed integer i.e. Int32.

To implicitly convert an Int32 to a Decimal, firstly set a Int32 value.

int val = 392;

To convert Int32 to decimal, assign the value.

decimal d;
d = val;

Let us see another example.

Example

using System;
public class Demo {
   public static void Main() {
      int val = 767;
      decimal d;
      Console.WriteLine("Implicit conversion from Int32 (integer) to Decimal");
      d = val;
      Console.WriteLine("Decimal : "+dec);
   }
}

Updated on: 23-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements