The source code to demonstrate the use of Truncate() method of Math class is given below. The given program is compiled and executed successfully.
using System;
class Sample
{
//Entry point of Program
static public void Main()
{
decimal decNum = 123.4567m;
double dblNum = 123.4567;
Console.WriteLine("Demonstration of Truncate method: ");
Console.WriteLine(Math.Truncate(decNum));
Console.WriteLine(Math.Truncate(dblNum));
}
}
Output:
Demonstration of Truncate method:
123
123
Press any key to continue . . .
Program:
The source code to demonstrate the use of Truncate() method of Math class is given below. The given program is compiled and executed successfully.
Output: