在C#中使用Truncate方法删除小数点后的所有数字。
假设以下是我们的号码-
9.15M
要删除小数点后的数字,请使用Truncate()-
decimal.Truncate(9.15M)
让我们看完整的代码-
using System;
using System.Linq;
class Demo {
static void Main() {
decimal val = 9.15M;
Console.WriteLine(decimal.Truncate(val));
}
}输出结果
9