Sponsored Ad

Tuesday, July 26, 2011

Calculate Truncated Number from a Decimal Number in C#

If you want to truncate a given decimal number of double number, C# provide a function Math.Truncate() to return corresponding number.

The below code provide sample demo application for the same.

Calculate Truncated Number from a Decimal Number in C#

C# Example Code to truncate a given number:

using System;

namespace DemoConsoleApplication
{
    class Math_Truncate
    {
        static void Main(string[] args)
        {
            decimal dec_Number = 400.2222M;

            decimal Result = Math.Truncate(dec_Number);
            Console.WriteLine(" Truncated Number: " + Result);

            Console.ReadLine();
        }
    }
}

0 comments:

Post a Comment

Sponsored Ad

More Related Articles

Website Update

Followers