Home >Backend Development >C#.Net Tutorial >C# truncation method

C# truncation method

王林
王林forward
2023-09-06 09:29:061278browse

C# 截断方法

Use the Truncate method in C# to remove all digits after the decimal point.

Assume the following are our numbers -

20.35M

To remove the numbers after the decimal point, use Truncate() -

decimal.Truncate(20.35M)

Let’s see the complete code -

Example

using System;
using System.Linq;

class Demo {
   static void Main() {
      decimal dc = 20.35M;
      Console.WriteLine(dc.Truncate(val));
   }
}

The above is the detailed content of C# truncation method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete