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 223477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:13:30+00:00 2026-05-11T19:13:30+00:00

I’m having a bit of a curious problem with .NET and working with the

  • 0

I’m having a bit of a curious problem with .NET and working with the decimal type. My web application uses the following globalization settings:

<globalization culture="auto" enableClientBasedCulture="true"/>

With that in mind, consider the following: the decimal value 123.00 becomes £123.00 in GBP, and EUR 123,00 (note the comma). The problem I’m having appears when I want to go from a decimal value of 123,00 (EUR) back to GBP again, as it becomes 123,000 – which is a huge problem.

In this scenario, my application has consults a look up table based on the detected culture and shows prices in that currency. The problem only arises when the user has made a selection and the data is prepared for sending to our payment gateway, which convers the EUR 123,00 to 123,000.

Any ideas how I can overcome this?

  • 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-05-11T19:13:30+00:00Added an answer on May 11, 2026 at 7:13 pm

    Thanks to everyone who offered their experience and suggestions.

    Implementing a custom-type/structure for holding my own Decimal values wasn’t really what I was after, and wouldn’t really give me the functionality I needed (I can already display decimal values in the appropriate local currency/format, I just couldn’t convert them back into UK format when required).

    The problem was this line in the web config:

    <globalization culture="auto" enableClientBasedCulture="true"/>
    

    Setting culture = “auto” was allowing .NET to set the locale according to the values provided by the browser (incidentally, by the way, ‘enableClientBasedCulture’ is not implemented, according to MSDN – so you can omit it). Hence, if a visitor from France (with language ‘fr-FR’ configured in their browser) visited our site, all the number formatting would work perfectly (correct decimal separator and currency symbol) but I’d have a problem later when trying to conver that number from it’s European format to the UK/US format I required.

    It’s odd, but converting “123.00” to the ‘fr-FR’ locale produces a FormatException because “123.00” is not valid in the French locale (it expects “123,00”). But, converting “123,00” (fr-FR) to the UK/US ‘en-GB’ or ‘en-US’ format does NOT produce an error, but instead the value becomes “123,000”. I believe this should throw a FormatException because it is not acceptable to add another zero.

    The solution I implemented was as follows:

    1. Set culture=”auto” to culture=”en-GB” in web.config.
    2. Use Decimal.ToString(“c”, ni) – where ‘ni’ is custom NumberFormatInfo class.

    Since my existing code connects to our data source to retrieve the correct decimal values dependant on country, all I had now was a formatting issue. So, to format a number according to the ‘fr-FR’ locale, you can do:

    NumberFormatInfo ni = Globalization.CultureInfo.GetCultureInfo("fr-FR").NumberFormat;
    Decimal.ToString("c", ni);
    

    In this setup, all my decimal values (internally) are always treated as en-GB decimals, and thus in the format I require. In other words, my application did not require the flexibility of being able to change the settings that apply to the entire current thread; rather just the opposite: I only cared about formatting the values differently.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.