How to use the decimal truncate() method to erase all the numbers after the decimal place in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(decimal.Truncate(13.1M));
            Console.WriteLine(decimal.Truncate(13.5M));
            Console.WriteLine(decimal.Truncate(13.67M));
            Console.WriteLine(decimal.Truncate(13.99M));
        }
    }
}

/*
run:
   
13
13
13
13

*/

 



answered Jan 17, 2017 by avibootz
...