Given a Double real number, the task is to convert it into Integer in C#. There are mainly 3 ways to convert Double to Integer as follows:
Input: double = 3452.234 Output: 3452 Input: double = 98.23 Output: 98
1. Using Typecasting: This technique is a very simple and user friendly.
2. Using Math.round(): This method returns the nearest integer.
3. UsingDecimal.ToInt32(): This method is used to convert the value of the specified Decimal to the equivalent 32-bit signed integer.
- Different ways to convert String to Integer in C#
- Convert string to integer in Python
- Convert integer to string in Python
- How to Convert Integer Array to List in C#?
- C# Program to Convert a Binary String to an Integer
- C# Program to Convert the Octal String to an Integer Number
- Different Ways to Convert Char Array to String in C#
- double Keyword in C#
- Double.IsNaN() Method in C#
- Double.IsInfinity() Method in C#
- Double.IsPositiveInfinity() Method in C#
- Double.IsNegativeInfinity() Method in C#
- C# | Double.ToString() Method | Set - 1
- Double.GetHashCode() Method in C#
- Double.IsFinite() Method in C#
- Double.GetTypeCode() Method in C#
- C# | Double.ToString() Method | Set - 2
- Double.CompareTo Method in C# with Examples
- Double.Equals() Method in C# with Examples
- How to Pad an Integer Number With Leading Zeroes in C#?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.