Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
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
Advertisements
