C# truncation method

王林
Release: 2023-09-06 09:29:06
forward
1225 people have browsed it

C# 截断方法

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

Assume the following are our numbers -

20.35M
Copy after login

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

decimal.Truncate(20.35M)
Copy after login

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));
   }
}
Copy after login

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

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template