C# program to remove all the numbers after decimal places

CsharpProgrammingServer Side Programming

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
raja
Published on 05-Sep-2018 10:42:20
Advertisements