C# Program to convert an Int32 value to a decimal

CsharpProgrammingServer Side Programming

To convert an Int32 value to a decimal, use the Convert.ToDecimal() method.

Int32 represents a 32-bit signed integer.

Let’s say the following is our Int32 value.

int val = 2923;

Now to convert it to decimal.

decimal decVal = Convert.ToDecimal(val);

Let us see the complete example.


 Live Demo

using System;
public class Demo {
   public static void Main() {
      int val = 2923;
      decimal decVal = Convert.ToDecimal(val);
      Console.WriteLine("Converted Int32 {0} to decimal {1:N2} value ", val, decVal);


Converted Int32 2923 to decimal 2,923.00 value
Updated on 23-Jun-2020 08:48:26