- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to remove all the numbers after decimal places
Use the Truncate method in C# to remove all the number after decimal places.
Let’s say the following is our number −
9.15M
To remove the numbers after decimal places, use Truncate() −
decimal.Truncate(9.15M)
Let us see the complete code −
Example
using System; using System.Linq; class Demo { static void Main() { decimal val = 9.15M; Console.WriteLine(decimal.Truncate(val)); } }
Output
9
Advertisements