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

 Live Demo

using System;
using System.Linq;
class Demo {
   static void Main() {
      decimal val = 9.15M;
      Console.WriteLine(decimal.Truncate(val));
   }
}

Output

9

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 22-Jun-2020

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements