
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# Truncate Method
Use the Truncate method in C# to remove all the numbers after decimal places.
Let’s say the following is our number −
20.35M
To remove the numbers after decimal places, use Truncate() −
decimal.Truncate(20.35M)
Let us see the comple code −
Example
using System; using System.Linq; class Demo { static void Main() { decimal dc = 20.35M; Console.WriteLine(dc.Truncate(val)); } }
- Related Articles
- How to truncate a file in C#?
- Truncate with condition in MySQL?
- Truncate BigDecimal value in Java
- MySQL truncate text with ellipsis?
- Difference between DROP and Truncate
- Primer CSS Truncate Custom Max Widths
- How to truncate a file in Java?
- What is MySQL TRUNCATE command used for?
- How to truncate an array in JavaScript?
- How to Truncate a File in Golang?
- What is the use of MySQL TRUNCATE() function?
- How to truncate Key Length in Python Dictionary?
- How do I truncate tables properly in MySQL?
- Difference between Delete and truncate in sql query
- Performing truncate thresholding on an image using OpenCV

Advertisements