C# Decimal Truncate
Description
Decimal Truncate
returns the integral digits of the specified
Decimal; any fractional digits are discarded.
Syntax
Decimal.Truncate
has the following syntax.
public static decimal Truncate(
decimal d
)
Parameters
Decimal.Truncate
has the following parameters.
d
- The decimal number to truncate.
Returns
Decimal.Truncate
method returns The result of d rounded toward zero, to the nearest whole number.
Example
The following code example uses the Truncate method to discard the fractional digits of Decimal values.
using System;// w w w.j ava 2s.c o m
class MainClass
{
public static void Main( )
{
Console.WriteLine(decimal.Truncate( 123.456M ) );
}
}
The code above generates the following result.