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.

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
raja
Published on 14-Sep-2018 12:49:10
Advertisements