C# Program to convert an Int32 value to a decimal


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.

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);
   }
}

Output

Converted Int32 2923 to decimal 2,923.00 value

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 23-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements