Implicit conversion from Int32 to Decimal in C#

CsharpProgrammingServer Side Programming

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);
   }
}
raja
Published on 12-Sep-2018 12:44:30
Advertisements