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