Tuesday, 12 October 2010

How to Print Number in Currency Format using C#

Steps for this Program:

1. Use {0:C} to print double number in currency format.

2. This is applicable for all C# projects , either web or windows.

Program to Print values in Currency format:

using System;
using System.Collections.Generic;
using System.Text;

namespace TestConsole
{
    class CurrencyFormat
    {
        static void Main(string[] args)
        {
            double myCurrency = 123456.9854;

            Console.WriteLine("The given number is: {0}", myCurrency);
            Console.WriteLine("The given number in currency format is: {0:C}", myCurrency);
            Console.ReadLine();
        }
    }
}

Output of Currency Format is:

How Print Number in Currency Format using C#

No comments:

Post a Comment