Sponsored Ad

Sunday, March 13, 2011

How to Set number of Decimal Places using C#

This program will help you to control number of decimal points after decimal using C#. use F and then Number of decimal points.

How to Set number of Decimal Places using C#

C# Example to control decimal point

using System;
using System.Globalization;
namespace MyApp
{
    class decimal_formatting_class
    {
        static void Main()
        {
            double myAmount = 105.245;

            Console.WriteLine(myAmount.ToString("F2", CultureInfo.InvariantCulture));
            Console.WriteLine(myAmount.ToString("F4", CultureInfo.InvariantCulture));

            Console.Read();
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates