How-To Geek

Format a String as Currency in C#

When building a string for output to a web page, it’s useful to format any currency value in a human-friendly money format. This is extremely easy in C#.

The system format string works like this: {0:C}

For example, the following code example:

decimal moneyvalue = 1921.39m;
string html = String.Format("Order Total: {0:C}", moneyvalue);

Outputs the following:

Order Total: $1,921.39

It’s worth noting that you must pass in a numeric value to the String.Format statement. If you pass in a string value, it won’t format correctly. If your currency value is in a string, you need to convert it into a double first.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 11/27/06

Comments (23)

  1. Justin

    You can also use:

    decimal moneyvalue = 1921.39m;
    string html = “Order Total: ” + moneyvalue.ToString(“C”);

  2. Kingsley Magnus-Eweka

    how do i format the currency value i.e from $ to that isd from dollars to pounds using the string.format ?

  3. abdou

    I can give help I think look at control panel , regional option and look you can change your currency value there

  4. Soniya

    Ultimate one ..really helpful

  5. Barbaros Alp

    decimal moneyvalue = 1921.39m;

    You can use
    instead of

    by this way you get the formatted string just like currency, without Currency sign

  6. sameer

    by this way you get the formatted string just like currency, without Currency sign

    thanks i searching about this :)

  7. Joseph Marinaccio

    Thanks for a great article, direct and to the point!

    -Joseph Marinaccio
    Marinaccio Family Design

  8. Mehmet

    Thank you.

  9. Jeppe

    Is there a way to force the currency to be a specific one? Just because some has different regional settings it does not change the fact that a price is listed in (for example)pound.

  10. hk

    You can provide IFormatProvider. In this case you can do something like this

    using System.Globalization;

    decimal = moneyValue = 100.00m;
    string output = String.Format(CultureInfo.CurrentUICulture, “{0:C}”, moneyValue);

    With the above approach you don’t need to worry about culture specific format.

  11. jemala

    use this method
    public static string formatmoney(Decimal d)

    return String.Format(CultureInfo.CreateSpecificCulture(“en-us”), “{0:C}”, d);

  12. mahima

    thnx Barbaros Alp ..

  13. hn

    thanks jemala !!
    great help….

  14. Andy

    How if I’m writing a Curreny Conversion program on the Console of Visual Basic can i get the Dollar sign? I can get the pound sign by using {0:c2} but after the conversion I can’t get it to change to show a $ sign, I don’t know the code i need to write, Anybody know where I’m going wrong? Could really do with the help..
    Thanks everyone


  15. raj

    Can anyone help me in getting $ sign for a -ve amount.
    i.e. I want to conevrt -1000m to $ -1000.00 or (-) $ 1000.00 using any Format conversion.

    Thanks in advance.

  16. arun


  17. William Ross

    Thank you.

  18. Mike Oxbig

    Thanks this is just what I needed to format my moneys.

  19. Israel

    Also, you can define how many decimal show.

    For example:

    No decimal String.Format(“Order Total: {0:C0}”, moneyvalue);
    Four decimal String.Format(“Order Total: {0:C4}”, moneyvalue);

  20. Rajendra

    thank for help this site

  21. utham


  22. raj


  23. Andy

    Where is my coding going wrong here then, when I compile it using the .NET command prompt and run it correctly says “the cash value you entered was xx.xx” but doesnt have a £ sign there?? HELP.

    string cashValue;

    Console.WriteLine(“Please Enter a Cash Value”);
    cashValue = Console.ReadLine();
    Console.WriteLine(“The cash value you entered was {0:c}” , cashValue);

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!