Convert.ToInt32 Method in C#


Use the Convert.ToInt32() method to convert a specified value to a 32-bit signed integer.

Let us take a double variable.

double doubleNum = 11.53;

Now, we will convert it to Int32 using the Convert.ToInt32 method.

int intNum;
ntNum = Convert.ToInt32(doubleNum);

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      double doubleNum = 11.53;
      int intNum;
      intNum = Convert.ToInt32(doubleNum);
      Console.WriteLine("Converted {0} to {1}", doubleNum, intNum);
   }
}

Output

Converted 11.53 to 12

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 23-Jun-2020

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements