How to use System.Globalization.NumberFormatInfo for non US games?

We released a game the other day that uses XML files with floating point numbers in them for values in the game.

It's been reported to us that French users are not able to use the game unless they set their Region setting in Windows to be United States instead of France. The issue arises because in France (and other countries) they use a , as a decimal point instead of a period. When outr game tries to use a parseFloat on the numbers it crashes, unless they set their system to US mode.


I saw something in here about using System.Globalization.NumberFormatInfo to account for computers with different systems, but I have no earthly idea how to use that.

Can someone point out a simple method of making this work?

Here's a typical line from my code:

listCharacters[charNum].body = parseFloat(reader.content);

What would I do to make this compliant with computers in other countries with a different system of reading floating point numbers?

you'd use something like this:

listCharacters[charNum].body = float.Parse(reader.content, System.Globalization.CultureInfo.InvariantCulture);

You could also store the culture info as a variable to cut down the code a little


var ci = System.Globalization.CultureInfo.InvariantCulture;

If the numbers are things you put in and not user-input strings, you should use the invariant culture to do all parsing.

Or to put it in code

float f = float.Parse(reader.content, System.Globalization.CultureInfo.InvariantCulture);