Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:21:17+00:00 2026-06-17T23:21:17+00:00

In a previous .Net life, the way that I would format a currency (any

  • 0

In a previous .Net life, the way that I would format a currency (any currency) for the current language would be to do something like this:

public string FormatCurrencyValue(string symbol, decimal val) 
{
  var format = (NumberFormatInfo)CultureInfo.CurrentUICulture.NumberFormat.Clone();
  //overwrite the currency symbol with the one I want to display
  format.CurrencySymbol = symbol;
  //pass the format to ToString();
  return val.ToString("{0:C2}", format);
}

This returns the currency value, without any decimal parts, formatted for the given currency symbol, adjusted for the current culture – e.g. £50.00 for en-GB but 50,00£ for fr-FR.

The same code running under Windows Store produces {50:C}.

Looking at the (rather terrible) WinRT documentation, we do have the CurrencyFormatter class – but it was only after trying to fire the constructor with "£" as the parameter, and getting an ArgumentException (WinRT documentation is so special – it has practically no information about exceptions) that I realised it wanted an ISO currency symbol (in fairness the parameter name is currencyCode, but even so).

Now – I can get one of those as well, but the CurrencyFormatter has another issue that makes it unsuitable for currency formatting – you can only format double, long and ulong types – there’s no decimal overload – which can make for some interesting value errors in some situations.

So how to format currencies dynamically in WinRT.net?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:21:18+00:00Added an answer on June 17, 2026 at 11:21 pm

    I’ve found that you can still use old-style format strings with the NumberFormatInfo class – it’s just that, inexplicably, it doesn’t work when you use ToString. If you use String.Format instead, then it works.

    So we can rewrite the code in my question to:

    public string FormatCurrencyValue(string symbol, decimal val) 
    {
      var format = (NumberFormatInfo)CultureInfo.CurrentUICulture.NumberFormat.Clone();
      //overwrite the currency symbol with the one I want to display
      format.CurrencySymbol = symbol;
      //pass the format to String.Format
      return string.Format(format, "{0:C2}", val);
    }
    

    Which gives the desired result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a continuation of my previous question .NET regex engine returns no matches
Apologies if this is a dumb question. In previous ASP.NET projects, I've been using
This is a followup on the question: ASP.NET next/previous buttons to display single row
Previous working asp.net webforms app now throws this error: System.MissingMethodException: Method not found The
This is related to my previous question: Coalesce fields in a .net MVC 4
now that I've resolved my previous issue with clickatell: Impementing Clickatell CallBack in ASP.NET
Related to my previous posts I'm moving to .NET 4. I've found that using
Integrating SimpleModal with ASP.NET and MasterPages This is a continuation of a previous thread
Anyone know how previous/next links could be added to this carousel? http://jsfiddle.net/AndyMP/uA7NN/ /* home
I am upgrading a Windows Client application that was earlier .NET 1.1. The previous

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.